This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-01-24 19:59:49

rebelized39
Scratcher
Registered: 2012-01-11
Posts: 2

velocities

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

 

#2 2012-01-24 20:20:47

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Re: velocities

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)


6418,

Offline

 

#3 2012-01-25 19:41:14

rebelized39
Scratcher
Registered: 2012-01-11
Posts: 2

Re: velocities

thanks

Offline

 

#4 2012-01-27 07:44:37

mrscampau
New Scratcher
Registered: 2011-10-17
Posts: 1

Re: velocities

how do you use gravity? what scripts?

Offline

 

#5 2012-01-27 08:45:43

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: velocities

I think you may be looking for two things.
Velocity is also mistaken for gravity.  wink

The scratch wiki has tons of tutorials that you can use. For Velocity. And for Gravity

I hope this helps!  big_smile

Offline

 

#6 2012-01-27 10:29:14

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: velocities

Do you mean x velocity or y velocity?


Why

Offline

 

#7 2012-01-27 10:59:18

Servine
Scratcher
Registered: 2011-03-19
Posts: 1000+

Re: velocities

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.


http://bluetetrarpg.x10.mx/usercard/?name=Servine

Offline

 

#8 2012-01-27 14:20:21

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: velocities

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.  smile

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
end
That is the basic concept of velocity.  smile

Last edited by Magnie (2012-01-27 16:13:37)

Offline

 

#9 2012-01-27 16:36:12

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: velocities

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


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

Board footer