Discuss Scratch

magnamanjang
Scratcher
16 posts

How do you make sprites jump?

How do you?
If you need my project then here it is! http://scratch.mit.edu/projects/45833704/
Thanks!
Magnamanjang
drmcw
Scratcher
1000+ posts

How do you make sprites jump?

whenup arrowkeypressedchangeyby20
would be a start for you, however I'm sure you'll soon find issues with it. You then need to rethink how you do the program, so look in the sticky topics and it should give you some ideas.
Godzillafreak
Scratcher
3 posts

How do you make sprites jump?

Just do this The numbers depends on how high you want the sprite to jump If you want to laugh go herehttp://scratch.mit.edu/studios/892116/
when spacekeypressedchangeyby...changeyby-...

Last edited by Godzillafreak (Jan. 31, 2015 21:27:49)

invisibowl
Scratcher
23 posts

How do you make sprites jump?

Depends. If you want to actually jump, then what drmcw suggested would be best. Otherwise (like if it's a top-down game) you could cheat like Zelda: A Link to the Past did and just have a shadow that moves in and out. Basically it would work like this - look at the scripts for Sprite8, which are also below:

whenclickedshowforeversetxtox positionofSprite1-0setytoy positionofSprite1-5ifkeyspacepressed?thenbroadcastjumpglide0.25secstox:x positionofSprite1-10y:y positionofSprite1-10glide0.25secstox:x positionofSprite1y:y positionofSprite1-2

Notice the
broadcastjump
block- this will theoretically help disable collision detection. For instance:

whenclickedforeveriftouchingmaze?thenturn180degreesmove3stepswhenIreceivejumpforeveriftouchingmaze?thendosomethingyougettheidea
ytaha
Scratcher
25 posts

How do you make sprites jump?

whenclickedsetvelocityto0 foreverchangevelocityby-1iftouchingground?thensetvelocityto0changeybyvelocity

Last edited by ytaha (Feb. 1, 2015 12:09:03)

brainstorm101
Scratcher
1000+ posts

How do you make sprites jump?

This is probably the easiest way:
whenspacekeypressedchangeyby20
peppermintpatty5
Scratcher
1000+ posts

How do you make sprites jump?

There are many, many ways of making a sprite jump. In my opinion, the simulated parabola and the cosine wave method are the most accurate, but this is an easy method to get you started:
whenspacekeypressedsetpowerto30repeatuntilpower<0.05gotox:xpositiony:yposition+powersetpowertopower/1.25repeatuntilpower>30.0gotox:xpositiony:yposition-powersetpowertopower*1.25
ealgase
Scratcher
100+ posts

How do you make sprites jump?

whenup arrowkeypressedrepeat2changeyby2repeat5changeyby3wait.3secsrepeat2changeyby-2repeat5changeyby-3
LexHarley
Scratcher
93 posts

How do you make sprites jump?

magnamanjang wrote:

How do you?
If you need my project then here it is! http://scratch.mit.edu/projects/45833704/
Thanks!
Magnamanjang
A simple, but well- animated way to have a character jump would be this:
whenUp Arrowkeypressedrepeat10wait0.01secschangeyby1.5repeat10wait0.01secschangeyby-1.5

Hope you make a great game!

Last edited by LexHarley (July 6, 2015 14:59:02)

msilby
Scratcher
2 posts

How do you make sprites jump?

magnamanjang wrote:

How do you?
If you need my project then here it is! http://scratch.mit.edu/projects/45833704/
Thanks!
Magnamanjang

I looked at your project. It looked like Pico was always jumping a short distance (which looked like a vibration). I did a quick remix using the up arrow to control the jump and simulated gravity to fall back down. Hope this is helpful.

http://scratch.mit.edu/projects/45946656/

Powered by DjangoBB