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

2013/4/6

Boss moving

GrimCreeper312 GrimCreeper312

2013/4/6

#
i want it so that my boss moves in randomally but not to cross the Y axis at 410, and if he hits the edge of the world to go a different way. What is the best way to do this.
danpost danpost

2013/4/6

#
Just give him a random chance to turn some on any move and program a turn when a world edge. And use this statement to prevent crossing 410 on the y:
// after moving
if (getY()>410) setLocation(getX(), 410);
GrimCreeper312 GrimCreeper312

2013/4/6

#
how would i make him go in a star like patern
danpost danpost

2013/4/6

#
Put a small transparent object at each place where the actor is to turn; if your actor moves faster than one pixel per act, use a 'for' loop to move one pixel at a time and check for intersection with transparent object. When object found, turn number of degrees required. For variance, you can specify the number of degrees to turn within the transparent object (or just specify the new direction of travel). If necessary, you can adjust the actor to the location of the transparent object to maintain the same line of travel each time around the path. The 'for' loop is unnecessary if you make the transparent object the size of the move amount of the actor (height and width), if placed close enough to where the actor will end up on a move.
You need to login to post a reply.