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

#1 2012-05-24 13:17:36

MP-R
New Scratcher
Registered: 2012-03-09
Posts: 14

Gravity

How do you make the gravity??

Thanks

Offline

 

#2 2012-05-24 13:30:38

Tbtemplex97
Scratcher
Registered: 2011-11-12
Posts: 100+

Re: Gravity

Very hard, it includes a few variables and precise coding, I recommend you use some else's


Online Status: http://blocks.scratchr.org/API.php?action=onlineStatus&user=Tbtemplex97
Darkspace Coming Soon!, Try the Singleplayer Demo

Offline

 

#3 2012-05-24 15:11:30

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

Re: Gravity

I wouldn't call it "very hard", but I guess everyone's different.

when gf clicked
set [yVelocity v] to [0]
forever
if <touching color [#dedfdf]?>
  set [yVelocity v] to [1]
else
  change [yVelocity v] by [-1]
end
change y by (yVelocity)
end

Last edited by RedRocker227 (2012-05-24 15:12:12)


Why

Offline

 

#4 2012-05-24 15:21:20

Tbtemplex97
Scratcher
Registered: 2011-11-12
Posts: 100+

Re: Gravity

RedRocker227 wrote:

I wouldn't call it "very hard", but I guess everyone's different.

I thought he ment when things bounce of the walls and stuff and fall at a realistic trajectory

Last edited by Tbtemplex97 (2012-05-24 15:21:32)


Online Status: http://blocks.scratchr.org/API.php?action=onlineStatus&amp;user=Tbtemplex97
Darkspace Coming Soon!, Try the Singleplayer Demo

Offline

 

#5 2012-05-24 15:25:29

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Gravity

Gravity uses velocity, which can confuse some people. I would recommend using this script:

when gf clicked
set [Vel v] to [0]
forever
  if <touching [edge v]?> // Replace this with whatever you use for "If touching ground"
    set [Vel v] to (((Vel) * (-1)) * (0.2))
    if <<(Vel) > (-0.1)> and <(Vel) < (0.1)>>
      set [Vel v] to [0]
    end
  end
  change y by (Vel) // This "Vel" variable is vertical velocity.
  set [Vel v] to ((Vel) * (0.83))
end
For a jumping script, you can use this:
When key [up arrow v] pressed
set [Vel v] to [10]
I hope this helps!  smile

Last edited by SciTecCf (2012-05-24 15:31:51)


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#6 2012-05-24 15:44:02

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

Re: Gravity

Tbtemplex97 wrote:

RedRocker227 wrote:

I wouldn't call it "very hard", but I guess everyone's different.

I thought he ment when things bounce of the walls and stuff and fall at a realistic trajectory

That's not what I think of when I hear the word "gravity", but okay.


Why

Offline

 

#7 2012-05-24 19:09:26

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Gravity

SciTecCf wrote:

Gravity uses velocity, which can confuse some people. I would recommend using this script:

when gf clicked
set [Vel v] to [0]
forever
  if <touching [edge v]?> // Replace this with whatever you use for "If touching ground"
    set [Vel v] to (((Vel) * (-1)) * (0.2))
    if <<(Vel) > (-0.1)> and <(Vel) < (0.1)>>
      set [Vel v] to [0]
    end
  end
  change y by (Vel) // This "Vel" variable is vertical velocity.
  set [Vel v] to ((Vel) * (0.83))
end
For a jumping script, you can use this:
When key [up arrow v] pressed
set [Vel v] to [10]
I hope this helps!  smile

I tried it and it didn't work.  The sprite kept staying in the air.  Can you help me?


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#8 2012-05-24 19:11:31

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Gravity

RedRocker227 wrote:

I wouldn't call it "very hard", but I guess everyone's different.

when gf clicked
set [yVelocity v] to [0]
forever
if <touching color [#dedfdf]?>
  set [yVelocity v] to [1]
else
  change [yVelocity v] by [-1]
end
change y by (yVelocity)
end

Neither did this...


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

Board footer