I am trying to make a Mario-type game and I do not know how to make it so you can jump. PLEASE HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Offline
Check this project out http://scratch.mit.edu/projects/archmage/72848
It will give you jumping codes.
Last edited by archmage (2008-03-08 16:13:35)
Offline
I have dial-up internet which means that things load VERY slow. So I cannot download your project. Would you please show it to me on this forum? Also, how do you put smileys on your post?
Offline
<when green flag clicked>
<set{ yVelocity }to( 0
<forever>
<if> <touching[ ground
<set{ yVelocity }to( 1
<if> <key[ up arrow ]pressed?>
<set{ yVelocity }to( 15
<end>
<end>
<change{ yVelocity }by( -1
<change y by( <{ yVelocity }>
<end>
For smilies see http://scratch.mit.edu/forums/help.php#smilies
Last edited by archmage (2008-03-08 16:24:25)
Offline
Thanks a TON Archmage!!!!
Offline
<when[ space ]key pressed>
<forever if><key[ space ]pressed?>
<point in direction( 0
<move( 10 )steps>
<wait( 0.00001 )secs>
<move( 9 )steps>
<wait( 0.00001 )secs>
etc, etc, til u get to 1 (miss out the wait after 1), then:
<wait( 2.5 )secs>
<point in direction( 180
<move( 1 )steps>
<wait( 0.00001 )secs>
<move( 2 )steps>
<wait( 0.00001 )secs>
etc, etc, til u get to 10 (miss out the wait after 10), then:
<wait( 1 )secs> (if u want a delay after each jump, if u dont, type 0.01)
<end>
P.S. the mario must be either left/right or fixed. if the mario is free then this wont work and you'll end up with a fat-assed plumber landing on his head
PP.S. dont flame me for calling mario "fat-assed", flame the nintendo magazine
Last edited by teguki (2008-03-08 17:12:49)
Offline
Also,where is a good place to get Mario sprites? The one I'm using for some reason won't go into my scratch project.
Offline
For mario sprites go to http://www.spriters-resource.com/nintendo/mario/
Offline
Theres a very easy way to do it.
<when green flag clicked>
<forever if>< <not> <touching[ ground>>>>
<change y by( 5 )
<end>
Last edited by D97 (2008-03-09 11:22:27)
Offline
and to jump
<when green flag clicked>
<forever if><touching[ ground<< <and> >><key[ up arrow ]pressed?>
<repeat( 10 )
<change y by( 10 )
Offline
Read both of his posts, Teguki. The first one is a simple approximation of gravity.
Offline
The first script makes the character fall if he is not touching the ground. The second script therefore only needs to take teh character up, he will come back down automatically.
***
Its not the best way of doing it, mind you, as the second script does not interupt the first script, so he will be rising and falling at the same time. This has been overcome by making the amount he rises bigger, but there are better ways around it.
***
One way is by using acceleration and velocity.
You need a vertical velocity (Y-Velocity).
Your falling script, inside a loop, would be:
If touching ground
- - set (Y-Velocity) to 0
- ELSE
- - change (Y-Velocity) by -1
Change Y by (Y-Velocity) <-(not inside the "If", but sill inside the loop)
This makes the character fall, and the speed at which he falls gradullay increases.
Then your Jump button needs a script like:
If Key [up arrow] pressed AND (Y-Velocity)=0
- Set Y-Velocity to 5
This results in the character leaping upwards at a speed of 5 (because of the other script) but the speed at which he rises gradually decreases until he starts to fall again.
Offline
Good point - I didn't notice that
Offline
hey teguki, how do you change pictures into PNGS?
Offline