This site requires JavaScript, please enable it in your browser!
Greenfoot back

What is happening right now?


reply to How do you do this?

By danpost - about 5 hours ago
spider65 wrote...
I mean moving at random times right and left between two distinct points.
Then, you only need choose a random delay time (the number of act cycles before the next move) and add a field to determine if the actor is moving or is waiting for the timer to exhaust itself. The two distinct points (x-coordinate value of those points) needs to be saved in the actor to maintain the range of movement for the actor (or collision detection can be used if the actor "bumps" into objects at both ends of its range of movement). There are other ways to produce the behavior you want. If the number of acts required to move the actor from one point to the other is known, the timer can be used for both counting down the number of moves made and for counting down the act cycles when not moving; also, the limits (x-coordinate of the end-points) of movement would not have to be saved (the only requirement would be in the set-up -- placement of actor and initial values of the fields). Try to get some code to work and we will try to help fix any issues with it, if needed.

reply to why this not work............):<

By danpost - about 17 hours ago
I see two problems with the code given. The first is that the last comment line appears to have a line of code at the end of it. The other is that the last line refers to 'apple' which does not appear to be declared anywhere (I think you may have wanted 'leaf' there).

reply to Create a maze using a one-pixel actor subclass

By schwonko - 1 day ago
remark: I was not talking about drawing to the background image, but inside an actor method (e.g. as part of the constructor) to the actor itsself.