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

#1 2012-11-17 17:05:03

oshe10
Scratcher
Registered: 2012-06-21
Posts: 92

Gravity Script

Can someone please tell me how you make one??
~Oshe10


http://i.imgur.com/w4rS6.jpg

Offline

 

#2 2012-11-17 17:45:13

halfpint
Scratcher
Registered: 2011-10-27
Posts: 2

Re: Gravity Script

I don't know!!!!!!????

Offline

 

#3 2012-11-17 18:05:46

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Gravity Script

It depends a lot on what you're trying to do.  The most basic one is this:

when gf clicked
set [y vel v] to (0)
forever
change [y vel v] by (-1)
change y by (yvel)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#4 2012-11-20 19:59:26

oshe10
Scratcher
Registered: 2012-06-21
Posts: 92

Re: Gravity Script

That doesn't work!


http://i.imgur.com/w4rS6.jpg

Offline

 

#5 2012-11-21 00:23:45

bob6
Scratcher
Registered: 2010-07-01
Posts: 100+

Re: Gravity Script

Are you sure it doesn't work? it works pretty well to me. What do you mean by "it doesn't work" ? Can you explain please?


http://i46.tinypic.com/3148ksz.gif

Offline

 

#6 2012-11-21 00:31:24

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Offline

 

#7 2012-11-21 12:12:07

oshe10
Scratcher
Registered: 2012-06-21
Posts: 92

Re: Gravity Script

bob6 wrote:

Are you sure it doesn't work? it works pretty well to me. What do you mean by "it doesn't work" ? Can you explain please?

It makes my sprite go negative


http://i.imgur.com/w4rS6.jpg

Offline

 

#8 2012-11-21 13:13:40

muppetds
Scratcher
Registered: 2011-02-11
Posts: 1000+

Re: Gravity Script

oshe10 wrote:

bob6 wrote:

Are you sure it doesn't work? it works pretty well to me. What do you mean by "it doesn't work" ? Can you explain please?

It makes my sprite go negative

if you mean upside down click the button <-> next to the sprite image at the part where you can change the name of it


SCRATCH'S PARTLY INSANE RESIDENT 
http://internetometer.com/imagesmall/31691.pnghttp://bluetetrarpg.x10.mx/usercard/?name=muppetds

Offline

 

#9 2012-11-21 20:20:10

oshe10
Scratcher
Registered: 2012-06-21
Posts: 92

Re: Gravity Script

Not upside down. it makes the sprite go to the bottom of the screen


http://i.imgur.com/w4rS6.jpg

Offline

 

#10 2012-11-22 04:19:45

Llamalover
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Gravity Script

Then you need to create a script that will only let the gravity script work if your sprite is in the air/not on solid ground.


Be nice, I'm an old lady  wink

Offline

 

#11 2012-11-22 05:08:34

30-1
Scratcher
Registered: 2012-08-08
Posts: 100+

Re: Gravity Script

The scratch wiki.


http://i.imgur.com/ocOya7x.gif
I. Text I Based I Games I

Offline

 

#12 2012-11-22 08:31:47

rlojunior
Scratcher
Registered: 2010-08-11
Posts: 59

Re: Gravity Script

Here follow two scrips that really work.
The first one use the physics concept of aceleration:

when gf clicked
reset timer
forever
     change y by <[-10] * (timer)>

or ...

when gf clicked
forever
     change (speed) by [-5]
     change y by (speed)

Offline

 

#13 2012-11-22 10:19:50

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Gravity Script

If you want collision too, you should mention that, it helps us know exactly what kind of script you want.  I usually use something like this:

when gf clicked
set [yvel v] to (0)
forever
change [yvel v] by (-0.2)
change y by (yvel)
if<touching [wall/ground v]?>
set [yvel v] to ((-0.5)*(yvel))
change y by (yvel)
if<touching [wall/ground v]?>
change y by (yvel)
end
if<<key [up arrow v] pressed?> and <(yvel) > (0)>> // for jumping
set [yvel v] to (5)
end
end


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

Board footer