Discuss Scratch

SimplyProjects
Scratcher
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:
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
Scratcher
24 posts

Platform Script Jump Help

scratch342
Scratcher
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)


Messi dribbles everyone and scores. Hardly celebrates
Cristiano Ronaldo scores a 30 yard screamer. You can guess what he does
picopaper
Scratcher
500+ posts

Platform Script Jump 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!

Last edited by picopaper (Feb. 17, 2014 14:02:35)


if <(platypus) = [platypus]> then
set [platypus v] to [platypus]

Pigs with Jetpacks! (a game of porcine combat)

What is with all these kumquat sig– *gulp*
SimplyProjects
Scratcher
74 posts

Platform Script Jump Help

scratch342 wrote:

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
Scratcher
74 posts

Platform Script Jump Help

ehusted wrote:

This should help: http://scratch.mit.edu/projects/18043575/
Unshared.

picopaper wrote:

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
Scratcher
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
Scratcher
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

evilpacman10
Scratcher
87 posts

Platform Script Jump Help


This is the secondary account of @Jetpackturtle
evilpacman10
Scratcher
87 posts

Platform Script Jump Help

Try this coding: **Super Snake Ninja!**

This is the secondary account of @Jetpackturtle
Skelepound
Scratcher
100+ posts

Platform Script Jump Help

I've recently released a platformer called Pixelybear! You're welcome to use the platforming engine it uses!

Please support these threads for me! I need these to be supported a lot or else I can't finish my newest games!
Blurring Support for Vector Editor | Add back the USER ID block
Also, here's some links to my Scratch character's animation rig.
Skelepound Rig | Skelepound Rig + Preset Animations
I'm the forum helping siggy box! I sit below Skelepound's signature and help Scratchers! How? Well, I can…
Show you all the topics you have followed!
Show you all the topics you posted on!
And even show you all the newest topics!

————————————————–

It looks like you have found my super secret siggy text! I sometimes post updates and secrets for my games and projects here, so check back often! Speaking of updates, did you know I am thinking of making a Sans Simulator to celebrate 50 followers? Also, if you type the Konami Code in Pixelybear, you'll unlock cheats instantly! Well, that's all the secrets I have for now!

NOTICE: Remember, this place is secret, and I'd really like to keep it that way, so please don't tell anyone about this. If a kumquat finds out about this place, it's definitely not going to be good for me.

Powered by DjangoBB