Discuss Scratch

_Tigerjack_
Scratcher
36 posts

Help- How to make a sprite jump correctly- not fly!!!

Hello,
I'm making a platformer and really want to know how to make my sprite jump correctly. I made it so that every time the up arrow key is pressed, the sprite changes Y by 20. But if you hold down the Up arrow, it keeps on changing Y. I haven't figured out how to stop that but still keep the sprite moving sideways. Can anyone help? Here's the moving script (It's very basic):
when green flag clicked
set [ Costume#] to [1]
set [Lives:] to [3]
set size to (80) %
forever

if <not <touching [Solid] ?>> then
change y by (-10)


end
if <key [Up Arrow] pressed?> then
change y by (20)

end
if <key [Right Arrow] pressed?> then
change x by (15)

end
if <key [Left Arrow] pressed?> then
change x by (-15)


end
if <(Lives) = [0]> then

stop [All]
end

end
I wouldn't like to change this too much, but I will if it's the only way. Thanks!!!
_Tigerjack_
Scratcher
36 posts

Help- How to make a sprite jump correctly- not fly!!!

“Solid” Is a sprite, and “Lives” and “Costume#” are variables- they didn't turn out right.
deck26
Scratcher
1000+ posts

Help- How to make a sprite jump correctly- not fly!!!

So you should only allow the up arrow to have an effect when touching something solid.

So
forever

if <touching [Solid] ?> then
if <key [Up Arrow] pressed?> then
change y by (20)

end
else
change y by (-10)


end
if <key [Up Arrow] pressed?> then
change y by (20)

end
if <key [Right Arrow] pressed?> then
change x by (15)

end
if <key [Left Arrow] pressed?> then
change x by (-15)


end
if <(Lives) = [0]> then

stop [All]
end

end
I wouldn't like to change this too much, but I will if it's the only way. Thanks!!!
_Tigerjack_
Scratcher
36 posts

Help- How to make a sprite jump correctly- not fly!!!

Ok- I'l try that!
_Tigerjack_
Scratcher
36 posts

Help- How to make a sprite jump correctly- not fly!!!

It works!!! Thanks!!!
longyan
New Scratcher
1 post

Help- How to make a sprite jump correctly- not fly!!!

I was also creating a platformer with flying issues so thank you very much @deck26
deck26
Scratcher
1000+ posts

Help- How to make a sprite jump correctly- not fly!!!

longyan wrote:

I was also creating a platformer with flying issues so thank you very much @deck26
Good that this helped but no need to necropost and bring it back to the top of the forum just to thank me (or anyone). Just treat old help as being free with no need to acknowledge.
BKETmps
Scratcher
1 post

Help- How to make a sprite jump correctly- not fly!!!

My sprite keeps on flying up for some reason if you want to check it out here is the link https://scratch.mit.edu/projects/4022279/editor
Wyan100
Scratcher
1000+ posts

Help- How to make a sprite jump correctly- not fly!!!

BKETmps wrote:

My sprite keeps on flying up for some reason if you want to check it out here is the link https://scratch.mit.edu/projects/4022279/editor

Stop Necroposting Sans.
samurai_master123
Scratcher
100+ posts

Help- How to make a sprite jump correctly- not fly!!!

NECROPOST 101
XD
Hotcrossbuns19
Scratcher
24 posts

Help- How to make a sprite jump correctly- not fly!!!

samurai_master123 wrote:

NECROPOST 101
XD
I NEED ANSWER TO PLEASE
Kitkatz6040
Scratcher
1000+ posts

Help- How to make a sprite jump correctly- not fly!!!

Use this script (I'm sorry for necroposting but i need to help):
when green flag clicked
if <key [Up arrow v] pressed?> then
repeat (10)
change y by (15)
end
end
repeat until <touching [Ground Sprite v] ?>
change y by (-10)
end
Source: Scratch Wiki
Nezon
Scratcher
1000+ posts

Help- How to make a sprite jump correctly- not fly!!!

Requesting to close this as too much necroposting is going on.
Scratcheur007
Scratcher
44 posts

Help- How to make a sprite jump correctly- not fly!!!

when green flag clicked
set [jump] to [0]
forever
if <touching [platforme] ?> then
if <key [up arrow] pressed?> then
set [jump] to [12]
end
else
change [jump] by (-1)
end
change y by (jump)
end

Powered by DjangoBB