A game with acceleration/deceleation
A game with acceleration/deceleation
How would I make a game where the actor accelerates to a 30 and deceleates to a speed of -6 or so and make it so he can skid?
free world
|-----------------|
0% 100%
|-----------------|
0% 100%
- vrageprogrammer
- Posts: 566
- Joined: Wed Oct 31, 2007 2:59 pm
- Location: On top of a tree
- Contact:
Re: A game with acceleration/deceleation
Possible.
Hust check for input(i.e, Acceleration key)
If key is down, accelartion = accelaration + 1
If key is NOT down, acceleration = acceleration -1
Hust check for input(i.e, Acceleration key)
If key is down, accelartion = accelaration + 1
If key is NOT down, acceleration = acceleration -1
It was not Possible to determine the dimensions of the image....
- darksmaster923
- Posts: 1857
- Joined: Wed Jan 03, 2007 10:32 pm
- Location: Huntington Beach, California, USA
Re: A game with acceleration/deceleation
the main problem with that is that the script commands applied everything too fast. that would make the acceleration to a complete stop.vrageprogrammer wrote:Possible.
Hust check for input(i.e, Acceleration key)
If key is down, accelartion = accelaration + 1
If key is NOT down, acceleration = acceleration -1
Herp derp.
Re: A game with acceleration/deceleation
Either make the max acceleration something like 2 million, or use wait commands to make it take longer between acceleration.The second one could make it have blocky acceleration though.
Once I was sad, and I stopped being sad and was awesome instead.
True story.
True story.
Re: A game with acceleration/deceleation
Or use DeltaTime values:
ACC_SPEED [1] //+1 acc per sec
DELTA_TIME [0]
LAST_TIME [0]
ACCELERATION [0]
DELTA_TIME=self.time-StringCopy(LAST_TIME); //time passed by since last frame
ACCELERATION=StringCopy(ACCELERATION)+StringCopy(ACC_SPEED)*StringCopy(DELTA_TIME);
LAST_TIME=self.time;
This way you have a smoth transition which does not depend on the frame rate. You can also easily set the ACC_SPEED to other values during runtime, for example -1 to lower the speed.
ACC_SPEED [1] //+1 acc per sec
DELTA_TIME [0]
LAST_TIME [0]
ACCELERATION [0]
DELTA_TIME=self.time-StringCopy(LAST_TIME); //time passed by since last frame
ACCELERATION=StringCopy(ACCELERATION)+StringCopy(ACC_SPEED)*StringCopy(DELTA_TIME);
LAST_TIME=self.time;
This way you have a smoth transition which does not depend on the frame rate. You can also easily set the ACC_SPEED to other values during runtime, for example -1 to lower the speed.
Everyone can see the difficult, but only the wise can see the simple.
-----
-----