
-----------------------------------
Fashoomp
Sun Mar 25, 2007 11:54 am

Acceleration
-----------------------------------
Im trying to make an acceleration program for my racing game. I'm trying to figure out how to make it so the longer i hold the button, the quicker the number rises. The only i can think of is taking time off of the delay. But i dont want the speed to be an outrageous number. So i have a second variable that is = to the counter/50, so its not as big. The reason im stuck with the delay issue is because of deceleration. Because i want "down" to be breaks, i want it to stop much quicker than it starts.

-----------------------------------
Cervantes
Sun Mar 25, 2007 12:47 pm

RE:Acceleration
-----------------------------------
It's actually pretty easy. Have a variable store the car's speed. Each time through your loop, check if the accelerate button is pressed. If it is, add some constant value to the speed.

Each time through the loop, add the car's speed (velocity) to its position. Draw the car at its position.

-----------------------------------
Fashoomp
Sun Mar 25, 2007 2:11 pm

Re: Acceleration
-----------------------------------
How would i set a speed cap, because i dont want it going too fast. Also, i dont want it to have decimal numbers.

-----------------------------------
Saad85
Sun Mar 25, 2007 4:08 pm

RE:Acceleration
-----------------------------------
if speed