Gravity and Jumps in Scratch

id: 750748

category: Help with Scripts

posts: 8

Hii! I am a new scratcher(not that new, but still). I've been trying to use gravity and jumps in my projects recently. Anyone know how to make my sprite stop falling after landing on an object and also stop pausing midair?
MineTurte MineTurte loading

Unknown05212 wrote:

Hii! I am a new scratcher(not that new, but still). I've been trying to use gravity and jumps in my projects recently. Anyone know how to make my sprite stop falling after landing on an object and also stop pausing midair?
when green flag clicked
forever
if <touching [ floor] ?> then
if <not <key [ space] pressed?>> then
set [ velocity] to [0]
else
repeat (10)
change [ velocity] by (1)
end
end
else
change [ velocity] by (-1)
end
end

when green flag clicked
forever
change y by (velocity)
end

Hope this helps!

Note: It might be a little buggy but it should work good enough. Feel free to refine the jumping part of it as that is the buggiest.
You shoudl prbaly just look it up, but i would recomend something like this
change y by (YV)
if <touching [Floor] ?> then
change y by ((0) - (YV)
set [YV] to ((0) - (YV))
end

and forever change YV by like -0.1

Same wroks for XV

YV=Y velocicyty
XV=X Veoeltiy

MineTurte wrote:

……Hope this helps!……This is JuniperActias. AKA Moth mommy. If I helped you out consider following Juni-Bug (my new account)!
Thanks! Sure I will


i recommend you to watch griffpatch's platformer tutorials
Norse7 Norse7 loading
or you could try something like this to prevent the sprite from looking like it's gliding up:
define ResolveCollision this is run without screen refresh
repeat until <not <touching [ground v] ?>>
change y by (1)
end
Hi, I need help figuring out how to make gravity compatible for this jumping script:
when green flag clicked
set [jump height v] to [13]
forever
if <key [up arrow v] pressed?> then
set [jump velocity v] to (jump height)
repeat until <(jump velocity) = [0]>
change y by (jump velocity)
change [jump velocity v] by (-1)
end
repeat until <(jump velocity) = (join [-] (jump height))>
change [jump velocity v] by (-1)
change y by (jump velocity)
end