Discuss Scratch

ScratchOS
Scratcher
17 posts

Slow Movement

Something has been bugging me on Scratch: When a hold down the right arrow key for my charater to walk right, he freezes/ lags until I let go to as when he will seem to teleport across the screen. Is it my browser :S What's happening? Does it happen to you? IS this a bug?
ScratchOS
Scratcher
17 posts

Slow Movement

No one?
eRKSToCK
Scratcher
23 posts

Slow Movement

It is a bug, and frequently happen to projects that are a little demanding on the CPU (Which means it happens to me all the time ). If your project goes under 30 fps its likely to lag when you press a button, you can see this in this game for example http://beta.scratch.mit.edu/projects/10085324/
I don't know why this happens, but as soon as you press a button on the keyboard the framerate WILL drop on more demanding games. There are ways to kind of fix it though, you can turn off key repeat, or make key repeat really slow, that makes the framerate much better for some reason.
Lightnin
Scratcher
1000+ posts

Slow Movement

Ah, I think we may need to tweak this…

Can one of you link to a nice example project?

I think what's happening is that something is buffering the keyboard events, but we don't want 'em buffered….
Kinderlabor
Scratcher
51 posts

Slow Movement

Not sure whether it's related, but here is a very simple test case that leads to severe lagging without any demanding operations involved. This one apparently has do do with the stop-this-script block : http://beta.scratch.mit.edu/projects/10054160/
eRKSToCK
Scratcher
23 posts

Slow Movement

Lightnin wrote:

Ah, I think we may need to tweak this…

Can one of you link to a nice example project?

I think what's happening is that something is buffering the keyboard events, but we don't want 'em buffered….

I did this one a while ago, its really simple. http://beta.scratch.mit.edu/projects/10030016/
draw a couple of hundred points (Hold the mouse, see the variable) about 1500 or 2000 is pretty good (It depends on how good your computer is though, you might need more points than that ), then hold space or something.
ScratchOS
Scratcher
17 posts

Slow Movement

Kinderlabor
Scratcher
51 posts

Slow Movement

ScratchOS wrote:

Your text to link here…

This one.

It seems not to be shared.
ScratchOS
Scratcher
17 posts

Slow Movement

hmmm Well I did press the share button… I'll try again..
ScratchOS
Scratcher
17 posts

Slow Movement

Odd, I press share but nope..
ScratchOS
Scratcher
17 posts

Slow Movement

I think it will work now (I mean it's shared)
ScratchOS
Scratcher
17 posts

Slow Movement

bump
Sonickyle
Scratcher
1000+ posts

Slow Movement

This bug really needs to be fixed. It can affect Side-Scrollers, Platformers, etc.
It doesn't matter what key you press, it'll still lag. I thought the arrow keys would only make it lag, but the whole keyboard does. :l
griffpatch
Scratcher
100+ posts

Slow Movement

This issue appear to be heavily linked to the Chrome browser and slower computers? (see: http://beta.scratch.mit.edu/discuss/topic/2135/)

If you have a scratch project with a loop that updates something on the screen, then scratch auto imposes a minimum delay of 1/30th of a second.

If your PC is fast, then the time scratch is waiting is used to process any other system events, and keyboard input, etc…
If your PC is not fast enough to execute all the scratch code and screen updating within that 1/30th of a second, then not only will the framerate drop from the smooth 30 frames a second, but scratch will no longer impose the idle time between frames, and thus does not provide the much needed time for the system to process system events and keyboard input… In other words it's rather self destructive

On my current game (unshared as yet I'm afraid) my project runs great on faster boxes, but on my older laptop (running chrome) it runs like a dog as soon as a key is held down or pressed… on releasing the key the game resumes… All that appears to happen in this time is the screen stops being updated, because the game skips and the character appears where he should have been if he had walking all that time.

Interestingly, swapping to use firefox on my slow laptop shows the game run without any such delay… So this looks to be a chrome/flash/scratch issue.

I'd also note that on my game you do not have to wait for the key repeat to kick in for the delay to occur… It happens as soon as the key is pressed down.
Sonickyle
Scratcher
1000+ posts

Slow Movement

griffpatch wrote:

This issue appear to be heavily linked to the Chrome browser and slower computers? (see: http://beta.scratch.mit.edu/discuss/topic/2135/)

If you have a scratch project with a loop that updates something on the screen, then scratch auto imposes a minimum delay of 1/30th of a second.

I'd also note that on my game you do not have to wait for the key repeat to kick in for the delay to occur… It happens as soon as the key is pressed down.
It doesn't even matter what key you press, which is odd. It just… happens.

This is something that really needs to be looked into. If you hold down a key for long enough, the Flash Plugin can actually crash.
botcrusher
Scratcher
500+ posts

Slow Movement

Oh pepper why are you so buggy (not that this whole issue is caused by it)
I hope there is some way to adress this. Such as more options to execute without screen refresh
AwokeKnowing
Scratcher
14 posts

Slow Movement

I'm also having the lag issue. if I insert at wait .05 then it works smooth but it lowers my frame rate. we need to work on the keyboard pipeline
dogzter
Scratcher
14 posts

Slow Movement

ScratchOS wrote:

No one?


hold shift and press green flag if it doesn't work tell me
JeffTuckey
New Scratcher
2 posts

Slow Movement

one simple thing that can help a bit in some cases (just helped me) is to adjust your keyboard repeat delay (the interval after ‘press and hold’ in which ‘hold’ is detected), and the keyboard repeat rate (the rate at which key click events are generated during the ‘hold’)

this makes for example a pong paddle (just goes up and down) easier and snappier to change direction.

for me the repeat delay was important to slow down. if you're running into problems on slow cpu, it may help you to reduce the keyboard repeat rate (but i'm just guessing on that)
JeffTuckey
New Scratcher
2 posts

Slow Movement

(you can adjust those keyboard settings from keyboard control from windows control panel)

Powered by DjangoBB