Discuss Scratch

Simply_A_Bookworm
Scratcher
21 posts

weird jumping glitch

Hi!
so currently i'm working on a warrior cats game and one of the codes i've programmed the sprite you control with is this:
when [up arrow v] key pressed
change y by (16)
wait (0.2) secs
change y by (-16)

See any problems so far? because as far as i can tell there isn't any (i'm not 100% sure though) but sometimes, randomly, whilst i'm running through the code that script will play. when i'm not even touching the keyboard or the code the charectar will just jump a bit. there isn't even a pattern!
can anyone tell me wh this is happening or how to fix it?

help

Last edited by Simply_A_Bookworm (May 30, 2021 19:26:06)


☀️ Sab ☀️
Bookworm, Cat lover, Artist, Fangirl

──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

Thingied
Scratcher
1000+ posts

weird jumping glitch

It runs when you're scrolling up.
3XAY
Scratcher
28 posts

weird jumping glitch

Simply_A_Bookworm wrote:

Hi!
so currently i'm working on a warrior cats game and one of the codes i've programmed the sprite you control with is this:
when [up arrow v] key pressed
change y by (16)
wait (0.2) secs
change y by (-16)

See any problems so far? because as far as i can tell there isn't any (i'm not 100% sure though) but sometimes, randomly, whilst i'm running through the code that script will play. when i'm not even touching the keyboard or the code the charectar will just jump a bit. there isn't even a pattern!
can anyone tell me wh this is happening or how to fix it?

help
If you scroll up, scratch acts like you pressed the up arrow key. Could be because of that.

Hey, check out my website, I coded everything myself!

Simply_A_Bookworm
Scratcher
21 posts

weird jumping glitch

Ohhh thanks didn’t know that!

☀️ Sab ☀️
Bookworm, Cat lover, Artist, Fangirl

──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

JacksonLens
Scratcher
100+ posts

weird jumping glitch

Yes, it runs when you scroll for some reason.

By the way, for more efficient jumping, do this:
when green flag clicked
forever
if <key [up arrow] pressed?> then
change y by (16)
wait (0.2) secs
change y by (-16)
end
end

There's an even better way to do this to make it even more smoother, which is using a variable. I like naming it velocity.
when green flag clicked
set [velocity] to [0]
forever
if <key [up arrow] pressed?> then
set [velocity] to [16]
end
if <<not <touching [Terrain/ground/whatever] ?>>
change [velocity] by (-1)
end
change y by (velocity)

Don't tell me you never asked, because you never asked. Right? But I can't resist the urge to help people who code like this

when [up arrow] key pressed
change y by (16)
wait (0.2) secs
change y by (-16)

No offense.

Why am I so annoying?

<- See how many posts I've made? Clearly I don't know what I'm doing.

By the way, if you have time, pay a visit to Alpha Island.

I need to stop engrossing myself in geography.

Powered by DjangoBB