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

#1 2012-03-14 14:50:57

cestelle
New Scratcher
Registered: 2012-03-09
Posts: 1

Gravity

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

 

#2 2012-03-14 15:12:42

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

Re: Gravity

Hello cestelle.  smile
You can probably find what you're looking for here.


6418,

Offline

 

#3 2012-03-14 15:53:27

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

Re: Gravity

Welcome to Scratch  smile

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)


Why

Offline

 

#4 2012-03-15 21:52:05

turkey3
Scratcher
Registered: 2011-12-04
Posts: 500+

Re: Gravity

RedRocker227 wrote:

Welcome to Scratch  smile

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

 

#5 2012-03-16 16:40:35

wasabi56
Scratcher
Registered: 2012-02-10
Posts: 500+

Offline

 

#6 2012-03-18 02:00:19

chanmanpartyman
Scratcher
Registered: 2011-05-30
Posts: 500+

Re: Gravity

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

 

Board footer