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

#1 2012-09-08 13:16:11

DjPenguin68
Scratcher
Registered: 2012-01-02
Posts: 8

Help me!

Im making a minecraft-like game,but i need help to make a gravity system,that includes:
-Falling down
-Jump
(optional:-Blocks that can fall)
Please help me,hey and if u want to team,pm me.

Offline

 

#2 2012-09-08 14:23:54

dvd4
Scratcher
Registered: 2010-06-30
Posts: 1000+

Re: Help me!

this is for the moving sprite

when gf clicked
forever
if (not touching the ground)
fall
end
if (touching ground and up pressed)
jump
end
end
and this is for the other one
when gf clicked
forever
if(touching move sprite)
wait(a bit)
fall
end
end
hope this helps

Last edited by dvd4 (2012-09-08 14:25:51)


I made a mod  big_smile  It's called blook!
http://i49.tinypic.com/16ia63p.png

Offline

 

#3 2012-09-08 21:50:28

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

Re: Help me!

Here is a basic simulation of jumping and gravity (using acceleration).  For block physics (falling blocks), it is very dependent on how you're rendering the blocks.  Are you re-drawing them each frame from an array or do you stamp them once in the beginning and edit them when needed?  Either way, I can tell you right now that block-physics will be quite advanced.

when gf clicked
set [y-vel v] to (0)
forever
change [y-vel v] by (-1)
change y by (y-vel)
if<touching [ground v]?>
change y by (1)
if<touching [ground v]?>
change y by (1)
if<touching [ground v]?>
change y by (1)
end
set [y-vel v] to (0)
else
change y by (y-vel)
if<(y-vel) > (-3)>
change [y-vel v] by (-1)
end


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

Offline

 

#4 2012-09-17 16:50:37

DjPenguin68
Scratcher
Registered: 2012-01-02
Posts: 8

Re: Help me!

dvd4 wrote:

this is for the moving sprite

when gf clicked
forever
if (not touching the ground)
fall
end
if (touching ground and up pressed)
jump
end
end
and this is for the other one
when gf clicked
forever
if(touching move sprite)
wait(a bit)
fall
end
end
hope this helps

Dude,where i find the (touching ground and up pressed) thing?And about the red jump and fall thingy?

Offline

 

#5 2012-09-17 17:07:08

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

Re: Help me!

DjPenguin68 wrote:

dvd4 wrote:

this is for the moving sprite

when gf clicked
forever
if <not<touching [the ground v]?>>
fall
end
if<<touching [ground v]?> and <key [up arrow v] pressed?>>
jump
end
end
and this is for the other one
when gf clicked
forever
if<touching [move sprite v]?>
wait (a bit) secs
fall
end
end
hope this helps

Dude,where i find the (touching ground and up pressed) thing?And about the red jump and fall thingy?

I fixed his blocks; they should be more recognizable now  smile   The red blocks are abbreviations for whatever code you have that currently does the indicated action.  Where "jump" is, for instance, you could put this:

change y by (50)
repeat until <touching [ground v]?>
change y by (-5)
end

Last edited by MoreGamesNow (2012-09-17 17:07:28)


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

Offline

 

#6 2012-09-17 22:07:29

bullelk12
Scratcher
Registered: 2012-05-26
Posts: 100+

Re: Help me!

when gf clicked
set [gravity v] to (-.4)
set [velocity v] to (0)
forever 
if <touching [ground v]?>
set [velocity v] to (0)
else
change [velocity v] by (gravity)
change y by (velocity)
This works well in most circumstances and isn't a tough script to tamper with.

Last edited by bullelk12 (2012-09-17 22:08:10)


http://mag.racked.eu/cimage/i6000/Achievement++get%21/Scratcher+love+minecraft%21/mca.png

Offline

 

Board footer