Complex Game is Occasionally Generating a Lot of Lag!

id: 750057

category: Help with Scripts

posts: 10

My game, https://scratch.mit.edu/projects/930833177/, is very complex and has almost 12,000 blocks. It is extremely complex and in some cases has frozen and crashed weak laptops and had them sent to be fixed XD It seems to run somewhat okay on my computer, which I'll list its stats below:

Windows NT 10.0, Opera 107.0.0.0, No Flash version detected

Anyway, it still ocasionally has extreme lag spikes and after, it takes a few seconds for my computer to catch up with the game. This is not really a problem, but for some people, it could actually cause a major issue with their computer and I've seen it happen already. So what I'm doing in the next update, v0.13, is doing a complete makeover of all scripts and creating one “event handler” sprite or whatever you want to call it, but I'm pretty much just limiting the project to one forever loop and one “when green flag clicked” block and using broadcasts to update individual sprites. This is definitely doable, but I'll need to know if this will even make a difference, or if there's anything else I can do, like limit the sprites which I already have done a bit.

And by the way, I'd call myself a pretty experienced coder, so please don't say something obvious like “Don't put custom blocks on run without screen refresh if they have a delay”.

Thanks, Chikematoodles.
AZBIDABOI AZBIDABOI loading
Can you simplify your game? I don't see much projects having over 12000 blocks of code

AZBIDABOI wrote:

(#2)
Can you simplify your game? I don't see much projects having over 12000 blocks of code

Not really, I kinda enjoy making large games XD
AZBIDABOI AZBIDABOI loading
Maybe add a turbowarp link or a link that helps the game run faster.

AZBIDABOI wrote:

(#4)
Maybe add a turbowarp link or a link that helps the game run faster.
I already have.
Also, the lag that I was talking about was on TurboWarp. The game is not really playable on regular Scratch XD
LUKiCREATE LUKiCREATE loading
It works perfectly fine for me, maybe try using Google Chrome?
SpyCoderX SpyCoderX loading

LUKiCREATE wrote:

It works perfectly fine for me, maybe try using Google Chrome?

Works fine on Edge. (In my opinion)
epicdude512 epicdude512 loading
On the FAQ, Opera is not offically supported by scratch, use either crome, safari, microsoft edge, or firefox
If you're looking to boil everything down to one forever loop, put this in the one loop.
forever
broadcast [loop 1 v]
broadcast [loop 2 v]
...
end
Malicondi Malicondi loading
The project works fine for me, on chrome on my Chromebook and PC.