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

#1 2012-12-14 12:36:33

Scratchmad525
Scratcher
Registered: 2012-12-14
Posts: 7

Gravity, volocicy.... What?

I want to do a platform game and I need gravity but all this stuff about volocity gets me confused. Can any one explain it?  smile

Offline

 

#2 2012-12-14 17:27:54

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Gravity, volocicy.... What?

Gravity is simply what it is in real-life; it makes a player fall.

Now onto velocity; velocity just stores a sprite's speed in a certain direction. So XVelocity woud be an sprite's speed left/right, and YVelocity would by a sprite's speed up/down. It's often used to help make movement in games more realistic.

Anyway, I hope that this helps! Also, hello Scratchmad525  and welcome to Scratch! I wish you good luck learning how to create a game!


http://i46.tinypic.com/35ismmc.png

Offline

 

#3 2012-12-14 19:37:45

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: Gravity, volocicy.... What?

Velocity is also "simply what it is in real life"; a constant change of the position of an object, by a certain amount, in a certain unit (pixels), in a certain direction.

What platformer games do, is merely simulate the physical concepts of gravity and velocity. The approach usually taken to simulate the latter, is to have both "X velocity" and "Y velocity" variables, that will be changed constantly by the game; then sprites can change their position by this amount at a constant rate.

I recommend you read a bit about simulating gravity using a "velocity" variable in the Scratch Wiki. The Wiki also has many articles about scrollers for you to read c:

Last edited by technoguyx (2012-12-14 19:37:59)


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#4 2012-12-21 05:09:22

Scratchmad525
Scratcher
Registered: 2012-12-14
Posts: 7

Re: Gravity, volocicy.... What?

Thanks everyone

Offline

 

#5 2012-12-21 06:59:00

Ideas
Scratcher
Registered: 2012-10-07
Posts: 100+

Re: Gravity, volocicy.... What?

My usage of velocity would be like this.
Eg
A sprite is at x0 y0, then it changes it's x velocity by 1 everytime the key right is pressed, meaning, everytime the key right is pressed, the sprite moves faster, to avoid this you have to set it to itself multiplied by a positive number closer to 1 to make a smooth movement (eg 0.9) and a positive number further to 1 to make a rough movement (eg 0.5). The same applies to moving left but all change variable blocks by, must be negative. Here is an example:

when gf clicked
set [xv v] to [0]
set [yv v] to [0]
set x to (xv)
set y to (yv)
forever
change x by (xv)
change y by (yv)
if <key [left arrow v] pressed?>
change [xv v] by [-1]
end
if <key [right arrow v] pressed?>
change [xv v] by [1]
end
if <touching colour [#903d3d]?>// touching the colour of the ground you want the sprite to touch
set [yv v] to [1]
if <key [up arrow v] pressed?>
set [yv v] to [10]
end
end
change [yv v] by [-0.5]
set [xv v] to ((xv)*[0.9])
end

Last edited by Ideas (2012-12-21 08:16:30)


http://img685.imageshack.us/img685/2010/screenshot20121110at132.pngI think that you must CLICK above

Offline

 

Board footer