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

2022/3/21

acceleration

ADAM68801 ADAM68801

2022/3/21

#
Hi, I have an actor And I want him to accelerated proportionally. What is the simplest way to do it?
danpost danpost

2022/4/22

#
Anything proportional to zero will be zero, so there must be some initial speed that is added non-proportionally to start it moving. The simplest way would be something like this:
if (speed == 0) speed++; else speed *=2;
However, the actor will quickly accelerate off to the edge of the window. Placing a cap on the speed might be helpful. Also, using location values that are smaller that one pixel would aid in a slower speed-up as well as allowing a smaller proportionality. Unfortunately, this becomes not so simple.
You need to login to post a reply.