Discuss Scratch

Unknown05212
New to Scratch
3 posts

Gravity and Jumps in Scratch

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
Scratcher
500+ posts

Gravity and Jumps in Scratch

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.

Last edited by MineTurte (March 28, 2024 12:53:11)


(pronouns are she/her). Advanced Alpha Game Studios Manager. Our website: https://aags2.w3spaces.com
This is JuniperActias. AKA Moth mommy. If I helped you out consider following Juni-Bug (my new account)!




If you found this secret, say uwu
Signature gradients here













52-94_Penguins
Scratcher
13 posts

Gravity and Jumps in Scratch

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

Last edited by 52-94_Penguins (March 28, 2024 14:34:33)

Unknown05212
New to Scratch
3 posts

Gravity and Jumps in Scratch

Thanks!

Last edited by Unknown05212 (March 30, 2024 11:09:16)

Unknown05212
New to Scratch
3 posts

Gravity and Jumps in Scratch

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


Last edited by Unknown05212 (March 30, 2024 11:13:16)

invalidaccess
Scratcher
69 posts

Gravity and Jumps in Scratch

i recommend you to watch griffpatch's platformer tutorials
Norse7
Scratcher
67 posts

Gravity and Jumps in Scratch

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

“It’s not a bug; it’s an undocumented feature.” ― Anonymous

when green flag clicked
forever
change [ awesomeness] by (1)
end
fireplaceman
Scratcher
1 post

Gravity and Jumps in Scratch

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

Powered by DjangoBB