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

2019/2/1

Actor Acceleration Question

Kakorat859 Kakorat859

2019/2/1

#
For an Actor such as the rocket from the asteroids1 game which continually accelerates upon user input, is it possible to set the maximum speed of the actor (i.e. cap the continual acceleration after a certain point), and, if so, how would you go about doing that?
danpost danpost

2019/2/1

#
Just add the condition along with the thrust key being down that the speed is less than whatever max value you are setting. For example:
if (Greenfoot.isKeyDown("up") && speed < 5) speed++;
You need to login to post a reply.