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

#1 2013-04-19 08:24:42

MishaisAwesome
Scratcher
Registered: 2013-01-25
Posts: 3

Smooth! Gravity and Moving Script!

Well I need a script for gravity and smooth moving!


I need it badly!

THX SCratch

Offline

 

#2 2013-04-19 08:26:45

Tohmis
Scratcher
Registered: 2013-02-18
Posts: 58

Re: Smooth! Gravity and Moving Script!

What for do you need it?
You definitely have to use variables.


Check out my new game
http://scratch.mit.edu/static/projects/Tohmis/3300878_sm.png

Offline

 

#3 2013-04-20 11:26:04

cauzality
New Scratcher
Registered: 2013-03-19
Posts: 44

Re: Smooth! Gravity and Moving Script!

gravity is a constant "acceleration" - that means changing your speed (not your position) by the same amount every frame, then changing your position by speed. So you WILL need a variable.

when gf clicked
set [y speed v] to [0]
forever
change y by (y speed)
if <touching [ground sprite v]?>
   set [y speed v] to [0]
   if <key [up arrow v] pressed?>
      set [y speed v] to [20]
      end
else
   change [y speed v] by [-3]
end
This is with a constant acceleration of -3 pixels per frame, which is what i usually use.

Offline

 

#4 2013-04-20 11:32:41

cauzality
New Scratcher
Registered: 2013-03-19
Posts: 44

Re: Smooth! Gravity and Moving Script!

oh yeah there's also a "List of Helpful Topics for Scripting" at the top of the "Help with Scripts" forum page - that should help.

Offline

 

Board footer