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

#1 2012-06-20 17:18:45

purplepickle
New Scratcher
Registered: 2012-04-14
Posts: 6

Gravity

how do u make something look real when it jumps, not just glide. Like gravity.  smile

Offline

 

#2 2012-06-20 17:23:21

skippito
Scratcher
Registered: 2012-03-17
Posts: 100+

Re: Gravity

Try this:

when gf clicked
set [Gravity v] to [0]
repeat [however long you want it to repeat]
  if <touching color [color of ground]>
    set [Gravity v] to [0]
    change y by [1]
    set [Gravity v] to [the larger this number is, the higher your sprite will jump]
  else
    change [Gravity v] by [-1]
    change y by (Gravity)
  end
end

Last edited by skippito (2012-06-20 18:34:10)

Offline

 

#3 2012-06-21 11:28:20

cbcollab
Scratcher
Registered: 2011-10-30
Posts: 38

Re: Gravity

try this script in your sprite that is effected by the gravity:

forever
   change y by (gravity)
   if <touching [ground v]?>
   set [gravity v] to [0]
   else
   set [gravity v] to [-1]
end
(you can also change those forever blocks to repeat)

Last edited by cbcollab (2012-06-21 11:35:34)


http://i40.tinypic.com/2z9i2c3.png

Offline

 

#4 2012-06-21 11:56:20

JH1010
Scratcher
Registered: 2012-05-31
Posts: 1000+

Re: Gravity

Gravity script.

when gf clicked
forever
if <touching [ground colour]>
set [y velocity v] to (0)
else
change [y velocity v] by (-0.4) // The lower the number the faster the sprite falls. 
end
when gf clicked
forever if <key [up arrow] is pressed>
set [y velocity v] to (9) // The higher the number the higher the sprite will jump.
end
when gf clicked
forever
change y by <y velocity v>
end

Offline

 

Board footer