Hi everyone,
I'm new at scratch and I want to make a game with gravity. I was hoping someone could explain to me how to add gravity to my game so that my sprite always comes back down to earth. I would really appreciate your help.
Thank you, Estelle.
Offline
Welcome to Scratch
Simulating gravity is actually pretty simple; just put this script on the sprite that's falling/jumping...
when green flag clicked set [y velocity v] to [0] forever if <touching color [#36E813]?>//Change the colour in this block to the colour of the ground. if <key [up arrow v] pressed?> set [y velocity v] to (10) else set [y velocity v] to (1) end else change [y velocity v] by (-1) end change y by (y velocity) end
Last edited by RedRocker227 (2012-03-14 15:53:40)
Offline
RedRocker227 wrote:
Welcome to Scratch
Simulating gravity is actually pretty simple; just put this script on the sprite that's falling/jumping...when green flag clicked set [y velocity v] to [0] forever if <touching color [#36E813]?>//Change the colour in this block to the colour of the ground. if <key [up arrow v] pressed?> set [y velocity v] to (10) else set [y velocity v] to (1) end else change [y velocity v] by (-1) end change y by (y velocity) end
I made a gravirty game butused a different script, and it worked really well
Offline
http://scratch.mit.edu/forums/viewtopic … 8#p1174788 View this for gravity and other things. This was used in the project linked with my sig, check it out for an example.
Offline