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

#1 2012-12-01 07:57:17

Curt2000
New Scratcher
Registered: 2012-11-30
Posts: 11

How Do I Make Gravity?

I am making a platformer. I need my sprite to be able to jump and fall. I want him to be able to move sideways while in the air as well. I don't want the sprite to carry on moving either. I also need to stop in mid jump if it his a platform. Can you please post a script for me below so I can complete it. I will share it if I finish it.

Offline

 

#2 2012-12-01 08:02:41

Curt2000
New Scratcher
Registered: 2012-11-30
Posts: 11

Re: How Do I Make Gravity?

When I said 'carry on moving either' I meant that if you hold the jump button he carries on moving.

Offline

 

#3 2012-12-01 08:24:58

soniku3
Scratcher
Registered: 2011-12-08
Posts: 1000+

Re: How Do I Make Gravity?

This belongs in ''Help with scripts''


internet's all about cats today.

Offline

 

#4 2012-12-01 08:43:48

Curt2000
New Scratcher
Registered: 2012-11-30
Posts: 11

Re: How Do I Make Gravity?

Thank you soniku3. Go to http://scratch.mit.edu/forums/viewtopic.php?pid=1456082#p1456082 to see the question carried on there.

Offline

 

#5 2012-12-01 08:48:37

Willpower
Scratcher
Registered: 2012-01-26
Posts: 1000+

Re: How Do I Make Gravity?

Here is the entry on the Scratch Wiki for simulating gravity including some scripts!
Here you go!
Hope it helps  big_smile

Last edited by Willpower (2012-12-01 08:49:11)


http://i49.tinypic.com/e84kdj.png

Offline

 

#6 2012-12-01 09:55:33

JakieMcCool
Scratcher
Registered: 2012-06-08
Posts: 27

Re: How Do I Make Gravity?

forever
if NOT touching color (color of the floor)
change y by -(num)

if <key up pressed> AND touching color (color of the floor)
change y by (num)

You should know how to make a sprite move left and right, include them in a different script so you can move left and right while in mid air.


http://jgametechnology.webs.com/

Offline

 

#7 2012-12-01 10:20:16

soniku3
Scratcher
Registered: 2011-12-08
Posts: 1000+

Re: How Do I Make Gravity?

JakieMcCool wrote:

forever
if NOT touching color (color of the floor)
change y by -(num)

if <key up pressed> AND touching color (color of the floor)
change y by (num)
You should know how to make a sprite move left and right, include them in a different script so you can move left and right while in mid air.


internet's all about cats today.

Offline

 

#8 2012-12-01 12:52:54

TheSupremeOverLord
Scratcher
Registered: 2012-09-29
Posts: 100+

Re: How Do I Make Gravity?

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

Last edited by TheSupremeOverLord (2012-12-01 12:53:23)


http://i1154.photobucket.com/albums/p522/lizzyhipo/MINIPIG.jpg

Offline

 

#9 2012-12-01 14:43:09

bubby3
Scratcher
Registered: 2012-11-19
Posts: 44

Re: How Do I Make Gravity?

It is the pretty much the same as one of the scripts of "Gravity Marble"

Offline

 

#10 2012-12-02 03:58:57

Curt2000
New Scratcher
Registered: 2012-11-30
Posts: 11

Re: How Do I Make Gravity?

Gravity Marble?

Offline

 

Board footer