Is this Lag?

My game (It’s not even a game yet) is running very slow. Is this lag? :thinking:

The issue here is the trees; you’re making 2000-4000 sprites at the start of the game. The default engine is primarily optimized around things that could feasibly run on the physical devices we support, like the Meowbit and Pygamer, which typically have a few hundred kilobytes of memory available; having that many sprites will make the devices run out of memory very quickly and crash, and most games have at most ~100 sprites at any given time.

If you’re not concerned with running on hardware, you can get away with it in this case like this:

setting the ghost flag on each tree and stump cuts away a LOT of the performance hit, but you still have the issue with start up time from making that many sprites (you’ll have the)

Easier solution is to just make the trees part of the tilemap, like this:

The tilemap is on the larger side, so it might end up having trouble on some devices, but it runs a lot faster that way :slight_smile: There’s a minor bug in that version, where sometimes it will pick two tiles on top of eachother and replace the already placed tiles. This can be worked around with the tilemaps extension ( by wrapping the set tile blocks in a condition that checks that both top tile and bottom tile are one of the default ones. You can also probably use array of all __ tiles to pick the locations to place the trees as well.

Thanks! This helps a lot! I’m making a survival based horror game, where you can cut down trees, so I needed many trees.

Many survival games, like Minecraft, generate new trees dynamically (or “on demand”) as you explore new areas. You could consider an approach like that which would save start up time, but you’d still have issues as the user explores more and more of the world unless you delete trees that are old or out of view.

Minecraft loads and unloads blocks in “chunks” so that blocks that are far away from you don’t slow down your computer. Arcade doesn’t have much to support approaches like that currently but it could probably be done in an extension.

Is there any extension you have in mind?

Unfortunately, no. I’d like to get around to building one, but I’m not aware of any examples yet.