Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Code
- SilasGamingTV
-
Scratcher
2 posts
Code
define Handle ground and jump
if <touching [Ground v]?> then
if <(Y speed) < (0)> then
repeat until <not <touching [Ground v]?>>
change y by (1)
end
else
repeat until <not <touching [Ground v]?>>
change y by (-1)
end
end
set [Y speed v] to (0)
end
// 1. Check if jump keys are pressed AND cooldown has finished
if <<<key [up arrow v] pressed?> or <<key [w v] pressed?> or <key [space v] pressed?>>> and <(jump cooldown) < (1)>> then
change y by (-1)
if <touching [Ground v]?> then
// Ground Jump
set [Y speed v] to (12)
set [jump cooldown v] to (10) // Prevents jumping again for 10 frames
start sound [High Whoosh v]
else
// Check Right Wall
change x by (2)
if <touching [Ground v]?> then
set [X speed v] to (-10)
set [Y speed v] to (13)
set [jump cooldown v] to (12) // Slightly longer cooldown for wall jumps
start sound [Low Whoosh v]
else
// Check Left Wall (only runs if NOT touching right wall)
change x by (-4)
if <touching [Ground v]?> then
set [X speed v] to (10)
set [Y speed v] to (13)
set [jump cooldown v] to (12)
start sound [Low Whoosh v]
end
change x by (2) // Move back to center
end
end
change y by (1)
end
Last edited by SilasGamingTV (Yesterday 16:31:16)
- FancyTigerDustBall
-
Scratcher
100+ posts
Code
Is there something wrong with your code? Also, sharing a link to your project will always give us an easier job.
- BrainGamer1234
-
Scratcher
100+ posts
Code
What exactly is the problem? HwS is for scratchers experiencing trouble coding, not for guides (leave them to the stickies)
- UncappedCyanMarker
-
Scratcher
100+ posts
Code
What exactly is the problem? HwS is for scratchers experiencing trouble coding, not for guides (leave them to the stickies)wait you can put guides in the stickies? never knew that
- Discussion Forums
- » Help with Scripts
-
» Code