I'm trying to figure out how to make a sprite accelerate and slow down like a car does using variables. Right now I'm stumped. Please help.
P.S.
I'm not very good at dissecting projects, so if you were to give me a link to one and tell me to look at the scripts, I most likely wouldn't learn much from it.
Offline
Projects that have some sort of acceleration system utilize the idea of velocity - instead of directly changing the car's movement, it increases or decreases a variable, which in turn is the amount the car moves by. The result when using a basic "change velocity by ___" script is a linear increase in speed. From the wiki, here's an example of what a basic velocity script would look like:
Feel free to check out the wiki article as well.
Last edited by Harakou (2011-07-31 21:03:50)
Offline
A script like this
/When Green Flag Clicked\
[Forever]
[]Move (variable) steps]
[end forever]
Then another script like
/When Green Flag Clicked\
[Forever]
[][if <up arrow key pressed>]
[][][change (variable) by (1)
[][else]
[][][change variable by (-0.5)]
[][end if, else]
[end forever]
Try that
In the paint editor make sure that the car sprite is pointing right
Offline
good job again, Harakou. When are you a mod?
Offline