Discuss Scratch

Skeptik
Scratcher
11 posts

Problems with lag

This is a simple game I made up as a test. I found it almost unplayable; it suddenly lags out sometimes on my desktop, which is reasonably new, and on older computers, it's unplayable. Is this a problem with scratch or my code?
ErnieParke
Scratcher
1000+ posts

Problems with lag

Probably the issue is neither, but instead Flash. Awhile ago, Adobe pushed an update which removed support for PixelBender, a key part of graphic effects and making them fast.

The problem this causes (most of it at least) is part of Witch2; you applied a graphical effect. Now, you're not applying it over and over, so why should it matter? Because of the way Scratch works.

Instead of making a “temporary” version of the costume and using that for reference, Scratch applies the effect to the rendered version. So it has to do it every frame, not once (or until it the effects are changed). And then thanks to the Flash update, that equals lag. More then it should.

I recommend that you remove the graphic effects block in Witch2. And if you want to, you can remove it from the key, although that seems to be perfectly fine.

My thoughts,

ErnieParke

Skeptik
Scratcher
11 posts

Problems with lag

Thank you for the advice ErnieParke, it seems to have worked and it's not something I would have guessed. I thought it might be a Flash issue but that seemed unlikely. I guess these problems occur even in the biggest name systems.

I guess the best thing is to prepare each ‘effect’ externally and then import.

Do you happen to know why i usually have to start the game twice to get it working? i.e. press green flag, red hex, green flag ?
Sonickyle
Scratcher
1000+ posts

Problems with lag

Skeptik wrote:

Thank you for the advice ErnieParke, it seems to have worked and it's not something I would have guessed. I thought it might be a Flash issue but that seemed unlikely. I guess these problems occur even in the biggest name systems.

I guess the best thing is to prepare each ‘effect’ externally and then import.

Do you happen to know why i usually have to start the game twice to get it working? i.e. press green flag, red hex, green flag ?

Do you have any scripts that rely on variables, like this?
when green flag clicked
forever

if <(variable) = [1]> then
...
end
end

If you are resetting variables when the Green Flag is clicked, the you need to add a
wait (0.1) secs
in between the When green flag clicked and Forever:
when green flag clicked
wait (0.1) secs
forever

if <(variable) = [1]> then
...
end
end
Many times have I made this mistake.

No I don't make projects anymore. I left some time ago.
I only check the forums every now and then, but other than that consider me retired.
inlovewithfate
Scratcher
18 posts

Problems with lag

Skeptik wrote:

Do you happen to know why i usually have to start the game twice to get it working? i.e. press green flag, red hex, green flag ?


Your project starts out with the VictoryStatus variable set to 1. This indicates that the game is already won, and that affects the actions of many of your sprites. The witches don't go through their loops, for example.

If you add a set VictoryStatus to 0 block right after the when Green Flag clicked hat in your Directions sprite script, it should fix things.
Skeptik
Scratcher
11 posts

Problems with lag

Thanks for the help, I think it's sorted out that bug. Current Version

I noticed it's still a bit laggy. I guess you have to do all the changes to the sprite as separate costumes, created in Inkscape et al, and then import. I don't have the skills and can't draw, so i'll leave it for now.
scubajerry
Scratcher
1000+ posts

Problems with lag

If it was the key response that was laggy, look at my remix

You also need to rotate the costumes 90 degrees CW
ScratchJahd2011
Scratcher
500+ posts

Problems with lag

Also, ghost effect blocks do not cause lag.

Like these blocks:
change [ghost v] effect by (*)
set [ghost v] effect to (*)

…..
Skeptik
Scratcher
11 posts

Problems with lag

scubajerry wrote:

You also need to rotate the costumes 90 degrees CW

I can see you changed the crab direction, but crabs scuttle sideways for the most part.

Last edited by Skeptik (Feb. 9, 2014 17:31:46)

Skeptik
Scratcher
11 posts

Problems with lag

scubajerry wrote:

If it was the key response that was laggy, look at my remix


I had a look through but I can't find what's different with regards to the key?

Powered by DjangoBB