i want to know how to put in velocities
i'm trying to think of a new project for me to make
though i want it to have to do with velocity ad a little gravity.......
please just someone post a script of how to put in velocity
or just give me an idea on what to make as my next game.
Offline
This is some basic gravity for a sprite.
<when green flag clicked>
<set{ Gravity }to( 50
<when green flag clicked>
<forever>
<change y by( ((<{ Gravity }><-> 50 ))
<when green flag clicked>
<forever if><touching[ Edge
<set{ Gravity }to( <pick random( 51 )to( 55
<when green flag clicked>
<forever><change{ Gravty }by( -0.1
That is what I usually do.
Sorry if it's hard to read.
Last edited by CheeseMunchy (2012-01-24 20:26:18)
Offline
I think you may be looking for two things.
Velocity is also mistaken for gravity.
The scratch wiki has tons of tutorials that you can use. For Velocity. And for Gravity
I hope this helps!
Offline
Do you mean x velocity or y velocity?
Offline
All I can say to contribute to this is that if you need both horizontal AND vertical velocity, you need TWO hat blocks. Hat blocks are the ones that start a script.
Also, if you are making a platformer, you should use a sensor costume.
Now that misc. is gone, I write sentences properly, and don't use internet slang. Maybe it was for the best.
Offline
You have the x and y of the sprite, then you have two more variables for x velocity and y velocity.
To move the sprite, you have x change by x velocity and y by y velocity. Then you have the controls change the x velocity and y velocity.
http://scratch.mit.edu/projects/Magnie/2271296 is a small example of velocity.
when gf clicked set [xvel] to (0) set [yvel] to (0) forever change x by (xvel) change y by (yvel) if <key [up arrow v] pressed?> change [yvel] by (0.1) end if <key [down arrow v] pressed?> change [yvel] by (-0.1) end if <key [right arrow v] pressed?> change [xvel] by (0.1) end if <key [left arrow v] pressed?> change [xvel] by (-0.1) end endThat is the basic concept of velocity.
Last edited by Magnie (2012-01-27 16:13:37)
Offline
Servine wrote:
All I can say to contribute to this is that if you need both horizontal AND vertical velocity, you need TWO hat blocks. Hat blocks are the ones that start a script.
Also, if you are making a platformer, you should use a sensor costume.
Now that misc. is gone, I write sentences properly, and don't use internet slang. Maybe it was for the best.
You don't necessarily need two hat blocks. It can be accomplished with one. Anyway, if you want a tutorial on x and y velocity in platformers see this
Offline