Discuss Scratch

SWASSA
Scratcher
10 posts

Platforming Script (Please Help!)


Hi guys! I am trying to make my own platforming script. The move left and right script works perfectly with the animation, but I can't seem to make the falling script work! This is how the script looks right now:
when green flag clicked
set rotation style [left-right]
set size to (50) %
set [Yv] to [0]
forever
if <<key [right arrow] pressed?> or <key [ left arrow] pressed?>> then
if <key [right arrow] pressed?> then
point in direction (-90)
move
end
if <key [ right arrow] pressed?> then
point in direction (90)
move
end
else
switch costume to [costume1]
end
change y by (Yv)
if <not <touching [ground] ?>> then
if <not <key [up arrow] pressed?>> then
change [Yv] by (-1)
end
if <touching [ground] ?> then
set [Yv] to [0]
end
else
if <key [up arrow] pressed?> then
change [Yv] by (1)
if <[Yv] > [5]> then
set [Yv] to [0]
end
end
wait until <not <key [up arrow] pressed?>>
end
end
Heres the move script:
define move
move (-5) steps
next costume
Can you help me with this? if you can, please comment. Thanks!!!

Last edited by SWASSA (March 8, 2018 15:33:00)

deck26
Scratcher
1000+ posts

Platforming Script (Please Help!)

There's no point checking for touching ground immediately after where you change Yv by -1 since the sprite hasn't moved since you entered that bit of code on the basis of not touching ground.

Sharing the project makes it easier to see what you have in context and means we know you've not made any mistakes copying the script.

Powered by DjangoBB

Standard | Mobile