Optimization help

Hey this is my game. I added lava recently and it spreads in your screen when it has an open spot on its left right or bottom. If you need to test click menu, and you will fly and ghost through walls. hold A to mine if you need to test making an open spot near lava. https://arcade.makecode.com/S35154-96391-14231-97749

P.S generating your cave takes a while wait a tiny bit. Also lava is hard to locate – look for a while.

1 Like

Very laggy on mobile

1 Like

Now imagine it on a school chrome book.

1 Like

Absalute nightmare

1 Like

Ur main problem is that it spikes to 200+ sprites every second. If you can do that without sprites, using (tile to left of (location)” code for example, it would be a lot less laggy.

1 Like

Thank you! That is a very good solution. One question, how can I make it ask if a tile next to the tiles location ask if a certain tile is there? Sorry, that’s the best way I could put it.

1 Like

This should work:


As a developer, I would find a different way to do the cheat-mode change, so that I still had access to the system menu. That way I could easily see the fps and sprite count whenever I wanted. For example, I can see you still have 44 sprites floating around, and idk if those are all those scorpion things or if they are left over from cave generation.

1 Like

Thank you so much!

1 Like

Finally had time to try it out, and it works like a charm :heart_suit:

1 Like

Hey, @WoofWoof may I have one more tinsy winsy bit of help with this project? When I added in the lava to my game, none of the tiles like TNT or bushes / rocks are generating. the only tile that is generating out of the tiles that are supposed to be placed on the ground are spikes.

1 Like

Yeah I’ll look at it when I get home. Make sure the link is updated.

1 Like

thank you! It is.

1 Like

Everything seems to be generating just fine for me…
Ok, the first time I ran it, I literally spawned on top of a TNT, but now trying it again nothing is generating, like you said. I think it’s a lag issue. There is probably enough lag during generation that by the time everything catches up, that Number2 variable is already set to 6, and that makes everything be spikes. I really think you should just stop using sprites for this stuff. Sprite movement is susceptible to lag, is inconsistent, etc etc, and spawning… 35 * 6 sprites is not gonna work well.
I changed the code to this:


And now I’m seeing TNT and some other stuff, so the lag is probably catching up around Number2 = 3, but that’s still not very good. Also, why are you using those “after (ms)” blocks? Just using the Pause(ms) block would do the exact same thing. The reason people use those “After” blocks is usually because pausing inside the block they are using would freeze the whole game, which some blocks like “On Game Update” will do. Since you’re inside a function, and that function is inside the OnStart block (which doesn’t pause the whole game when paused) you don’t need to use them!
Anyways, I decided to get rid of all that sprite stuff and just replaced that whole section with this:

Here’s the link so you can copy the code easily:

1 Like

@WoofWoof , I really appreciate you doing this! Your an awesome community member! thank you. And yes, I will stop using sprites for generation. :pensive_face:

2 Likes