Pages: 1
Topic closed
<blocks>
<when[ up arrow ]key pressed>
<if> <(<color[ color of character's feet ]is over[ color of platforms/ground)>
<set{ jumping? }to 1
( <repeat(20
<if> << <not> <color[ color for character's head]is over[ color of platforms/ground >>
<change y by(some number
<else>
<set{ jumping }to(0
<stop script>
<set{ jumping }to(0
<stop script>
</blocks>
This will make the character jump only if its feet are touching the ground. If its head hits a platform, it will bounce off. (I can't stand games where you can jump onto a platform from directly below it.) The variable jumping is so the character will not fall while it's jumping.
<blocks>
<when green flag clicked>
<forever if><< <not> <color[ color of feet ]is over[ color of platforms/ground >>
<if> <( <{ jumping }> <=> 0 )>
<change y by(some other number)
</blocks>
This is the gravity script. Change "some number" to make it jump faster. Change "some other number" to make it fall faster.
Hope this helps.
Offline
There is a block called "Change y by ____" in the motion section. If you us that block and say Change y by 5 and put a repeat 10 times around it, it will make the character go up then under that part on the same script put a repeat 10 times with a change y by -5 It will go back down.
Offline
SonicKJKH wrote:
Thanks! Now SA V.01 will be released in a few days.
I have a way on how to do gravity and jumping too...
<when green flag clicked>
<forever>
<if><touching color[ colorofground
<set{grounded }to( 1
<else>
<set{ grounded }to(0
<when green flag clicked>
<forever if><( grounded <=> 0 )>
<change y by( halfofjumpspeed
<when green flag clicked>
<forever if><<<( grounded <=> 1 )> <and><key[ up arrow ]pressed?> >>
<repeat( 10-20
<change y by( double gravity
Hope that helps you!
-Spine
Offline
here's an example: http://scratch.mit.edu/forums/viewtopic.php?id=14895
Offline
Topic closed
Pages: 1