Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Platform Script Jump Help
- SimplyProjects
-
74 posts
Platform Script Jump Help
I need help with a platform script. I would want to move left and right while jumping.
I tried this but it didn't work:
I tried this but it didn't work:
when I receive [message1 v]
switch costume to [costume1 v]
go to x: [-226] y: [-92]
show
forever
if <key [left arrow v] pressed?> then
move [-3] steps
if <key [up arrow v] pressed?> then
change y by [30]
set [ypos v] to (y position)
set [xpos v] to (x position)
change [ypos v] by [-30]
glide [0.5] secs to x: (xpos) y: (ypos)
end
end
if <key [right arrow v] pressed?> then
move [3] steps
if <key [up arrow v] pressed?> then
change y by [30]
set [ypos v] to (y position)
set [xpos v] to (x position)
change [ypos v] by [-30]
glide [0.5] secs to x: (xpos) y: (ypos)
- ehusted
-
24 posts
Platform Script Jump Help
This should help: http://scratch.mit.edu/projects/18043575/
- scratch342
-
55 posts
Platform Script Jump Help
there is a much simpler way.
when [up arrow v] key pressed
change y by (30)
wait (0.1) secs
change y by (-30)
Last edited by scratch342 (Feb. 17, 2014 07:12:13)
- picopaper
-
500+ posts
Platform Script Jump Help
Here are my favorite jumping scripts:
1: This is the simplest script I know that still works well.
2: This is a slightly more complex version that uses variables:
This gives a more realistic parabolic jump, but sinks into the ground on landing and tends to cause slight bouncing.
3: Here's my personal favorite jumping script, thanks to the impressive cobraguy. Take a look at him sometime; he does some great stuff!
Hope this helps!
1: This is the simplest script I know that still works well.
when green flag clicked
forever
if <touching [ground v]?> then
if <key [up arrow v] pressed?> then
repeat (20)
change y by (5)
end
end
else
change y by (-5)
end
end
2: This is a slightly more complex version that uses variables:
when green flag clicked
forever
if <touching [ground v]?> then
set [yv v] to [0]
change y by (5)
if <key [up arrow v] pressed?> then
set [yv v] to [10]
change y by (yv)
end
else
change [yv v] by (-0.5)
change y by (yv)
end
end
end
This gives a more realistic parabolic jump, but sinks into the ground on landing and tends to cause slight bouncing.
3: Here's my personal favorite jumping script, thanks to the impressive cobraguy. Take a look at him sometime; he does some great stuff!
when green flag clicked
forever
change [yv v] by (-0.5)
change y by (yv)
if <<touching [ground v]?> and <key [up arrow v] pressed?>> then
set [yv v] to [8]
end
if <touching [ground v]?> then
change y by ((yv) * (-1))
set [yv v] to [0]
end
end
Hope this helps!

Last edited by picopaper (Feb. 17, 2014 14:02:35)
- SimplyProjects
-
74 posts
Platform Script Jump Help
there is a much simpler way.when [up arrow v] key pressed
change y by (30)
wait (0.1) secs
change y by (-30)
Then I can't move while in air.
- SimplyProjects
-
74 posts
Platform Script Jump Help
http://scratch.mit.edu/projects/18043575/Unshared. This should help:
Here are my favorite jumping scripts:
1: This is the simplest script I know that still works well.when green flag clicked
forever
if <touching [ground v]?> then
if <key [up arrow v] pressed?> then
repeat (20)
change y by (5)
end
end
else
change y by (-5)
end
end
2: This is a slightly more complex version that uses variables:when green flag clicked
forever
if <touching [ground v]?> then
set [yv v] to [0]
change y by (5)
if <key [up arrow v] pressed?> then
set [yv v] to [10]
change y by (yv)
end
else
change [yv v] by (-0.5)
change y by (yv)
end
end
end
This gives a more realistic parabolic jump, but sinks into the ground on landing and tends to cause slight bouncing.
3: Here's my personal favorite jumping script, thanks to the impressive cobraguy. Take a look at him sometime; he does some great stuff!when green flag clicked
forever
change [yv v] by (-0.5)
change y by (yv)
if <<touching [ground v]?> and <key [up arrow v] pressed?>> then
set [yv v] to [8]
end
if <touching [ground v]?> then
change y by ((yv) * (-1))
set [yv v] to [0]
end
end
Hope this helps!
The first one helped but the rest crashed my browser and didn't save which I didn't care. Thanks

- EmmaJoyH
-
20 posts
Platform Script Jump Help
when green flag clicked
set [SpeedY v] to [0]
forever
if <key [up v] pressed?> then
set [SpeedY v] to [12 ]
end
change y by (SpeedY)
if <key [right v] pressed?> then
change x by (4)
end
if <key [left v] pressed?> then
change x by (-4)
end
end
- LLCoolJC
-
70 posts
Platform Script Jump Help
Not tested but should work
when gf clicked
set [velocity v] to (0)
forever
if <key [left arrow v] pressed?> then
change x by (-3)
if <touching [world v]> then
change x by (3)
end
end
if <key [right arrow v] pressed?> then
change x by (3)
if <touching [world v]> then
change x by (-3)
end
end
if <key [up arrow v] pressed?> then
change y by (-1)
if <touching [world v]?> then
set [velocity v] to (7)
end
change y by (1)
end
change [velocity v] by (-0.1)
change y by (velocity)
if <touching [world v]?> then
set [velocity v] to ((-0.5) * (velocity))
change y by (velocity)
if <touching [world v]?> then
change y by (velocity)
end
end
end
- Skelepound
-
100+ posts
Platform Script Jump Help
I've recently released a platformer called Pixelybear! You're welcome to use the platforming engine it uses!
- Discussion Forums
- » Help with Scripts
-
» Platform Script Jump Help