your script makes a sprite go right...
If you want a simple jumping script, use this (you might have to adjust it for your game)
If you want a more realistic gravity jump script use this: (you need a yv variable)when keyspace ▼pressediftouchingground ▼?repeatheightchange y byspeedrepeat untiltouchingground ▼?change y by-1*speed
when keyspace ▼pressediftouchingground ▼?setyv ▼to15or however high you want to jump
Hope this helped!whenclicked
foreverifnottouchingground ▼?changeyv ▼by-1or however fast you want it to go downelsesetyv ▼to0change y byyv
Offline
here is a quick example of realistic gravity jumping:
http://scratch.mit.edu/projects/aryabtsev/2453368
Offline
64no wrote:
Wait:
whenspace ▼key pressediftouching color ?repeatheightchange y byspeedrepeat untiltouching color ?change y by-1*speed
Scripts fixed by: TorbyFork234
Offline
64no wrote:
wait again:
whenspace ▼key pressediftouching color ?repeatheightchange y byspeedrepeat untiltouching color ?should that be capital?change y by-1*speed
Scripts fixed again by: TorbyFork234
Offline
64no wrote:
Wait:
whenspace ▼key pressediftouching colorEDC88C?repeatheightchange y byspeedrepeat untiltouching colorEDC88C
wrong;
TorbyFork234 wrote:
Scripts fixed by: [i][color=blue]TorbyFork234whenspace ▼key pressediftouching color ?repeatheightchange y byspeedrepeat untiltouching color ?change y by-1*speed
Right.
Offline
Here is how to make your sprite jump up and go down on a flat surface:
Now how to create a jumping sprite on any kind of a surface:whenup arrow ▼key pressedchange y by10change y by-10
whenup arrow ▼key pressedchange y by10repeat untiltouching color ?This needs to be the color of the ground.change y by1
Last edited by SOScratch (2012-04-08 16:49:12)
Offline
SOScratch wrote:
Here is how to make your sprite jump up and go down on a flat surface:
Now how to create a jumping sprite on any kind of a surface:whenup arrow ▼key pressedchange y by10change y by-10whenup arrow ▼key pressedchange y by10repeat untiltouching color ?This needs to be the color of the ground.change y by-1
Scripts fixed by COOLHOGS
EDIT: Ahh, I messed up the topic...
Offline
In order to do this without variables (which I've found can make things complicated) just do:
when keyup arrow ▼pressedglide1secs to xx positionyy position+10repeat untiltouchingground ▼change y by-2
Offline
If you use variables, you could do something like this:
This will allow you to move to the right while jumping.when keyup arrow ▼pressedset variableymaxto5change x byxvelchange y byyvelchange variableyvelby1ifyvel>ymaxset variableyveltoymaxif keyright arrow ▼pressedset variablexmaxto5change x byxvelchange variable xvel by1ifxvel>xmaxset variablexveltoxmaxifyvel=ymaxchange x byxvelchange y by0-(yvel)
Offline
On the sprite that's jumping;
whenclicked
sety velocityto0foreveriftouching color ?Change the colour in this block to the colour of the ground.ifkeyup arrow ▼pressed?sety velocity ▼to10elsesety velocity ▼to1elsechangey velocity ▼by-1change y byy velocity
Offline
aryabtsev wrote:
your script makes a sprite go right...
If you want a simple jumping script, use this (you might have to adjust it for your game)If you want a more realistic gravity jump script use this: (you need a yv variable)when keyspace ▼pressediftouchingground ▼?repeatheightchange y byspeedrepeat untiltouchingground ▼?change y by-1*speedwhen keyspace ▼pressediftouchingground ▼?setyv ▼to15or however high you want to jumpHope this helped!whenclicked
foreverifnottouchingground ▼?changeyv ▼by-1or however fast you want it to go downelsesetyv ▼to0change y byyv
that doesn't work.
Offline
@mythbusteranimator
Your first script doesn't allow the sprite's x-position to change while it is jumping. I don't think your second script works either.
Anyway, 64no seems to have gotten his/her answer, so it seems that additional solutions aren't really neccessary
However, it you (64no) still need help, here is the wiki article on jumping; it offers scripts of varying complexity (all of which should work).
Offline
Another way to do it would be this. You would have to have a variable "Gravity" set as -5 or some other negative number that controls how fast you fall. The higher the number after the minus, the faster you will fall. Use the "touching color []" block instead of the "touching ground" block. This script makes it so you can't "double jump".
[scratchblocks]
when key space v pressed
forever
if <touching ground v?>
change y by (10)
else
change y by (gravity)
end
[\scratchblocks]
If I did that right you should see a script. If not... sorry.
Unknown164
Offline