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

2012/8/11

Enemies getting stuck

davemib123 davemib123

2012/8/11

#
Hi Guys, making a space shooting game, but I'm having trouble with the enemy getting stuck on the right of the screen. Any thoughts on what is going on, the scenario is located here: http://www.greenfoot.org/scenarios/5799 the enemies get stuck after about 30 seconds or so the initial few are fine ....
erdelf erdelf

2012/8/11

#
In your drone class, in line 14 you set the speed, but it is possible that it is 0. change this
this.velocity = Greenfoot.getRandomNumber(6);
in
this.velocity = Greenfoot.getRandomNumber(6) +1;
SPower SPower

2012/8/11

#
That would also add 1 to the maximum result of velocity, to leave the max. as it was, do this:
velocity = Greenfoot.getRandomNumber(5) +1;
davemib123 davemib123

2012/8/11

#
rite ... greenfoot random numbers uses 0 as a number. Forgot about that one. Thanks for the info.
You need to login to post a reply.