Discuss Scratch

ItsLit1337
Scratcher
6 posts

How would I make a sprite jump?

I want to know how I could make a sprite jump.
amylaser
Scratcher
500+ posts

How would I make a sprite jump?

If you want realistic-looking jumping, you might want to use these scripts:

when green flag clicked
set [yvel v] to [0]
forever
change [yvel v] by (-1)
change y by (yvel)
if <touching [ground v] ?> then
change y by ((-1) * (yvel))
set [yvel v] to [0]
end
if <<key [space v] pressed?> and <(yvel) = [0]>> then
set [yvel v] to [12]
end
end

Keep in mind that these are only the very basic scripts - they are by no means efficient or robust. They're the bare minimum. If you want to make a plaformer game or something like that, you should look at griffpatch's platformer tutorial, here: https://scratch.mit.edu/projects/67727504/ It's very in-depth and explanatory.
TheCodePro123
Scratcher
100+ posts

How would I make a sprite jump?


amylaser wrote:

If you want realistic-looking jumping, you might want to use these scripts:

when green flag clicked
set [yvel v] to [0]
forever
change [yvel v] by (-1)
change y by (yvel)
if <touching [ground v] ?> then
change y by ((-1) * (yvel))
set [yvel v] to [0]
end
if <<key [space v] pressed?> and <(yvel) = [0]>> then
set [yvel v] to [12]
end
end

Keep in mind that these are only the very basic scripts - they are by no means efficient or robust. They're the bare minimum. If you want to make a plaformer game or something like that, you should look at griffpatch's platformer tutorial, here: https://scratch.mit.edu/projects/67727504/ It's very in-depth and explanatory.

Realistic jumping? Let's keep this topic very simple. Instead of that hard realistic jumping, try this. But it may not fit your project needs. This needs no platform but only goes back to the same level of where the sprite was once before.
when green flag clicked//starts the script
forever//makes script go forever
if <key[Up arrow v]pressed?> then// jump key
repeat [10]//for realistic jump
change y by [20]//makes sprite rise
end
repeat [10]//for realistic jump
change y by [-20]//makes sprite fall
end
end
end

Last edited by TheCodePro123 (Oct. 22, 2016 01:48:07)

Powered by DjangoBB