How do I optimize games on MakeCode Arcade?

There’s some methods that I think might work but I need some fact checking by other people. First making all the sprites that are off screen invisible. Functionally, invisible sprites only have 2 colors being transparent and non transparent since they can’t be seen however they can be hit with projectiles and melee attacks which only register for non transparent colors. So this reduces the amount of colors from 16 to 2 which probably boosts performance by a lot. Another thing is health bars. Health bars can be optimized even more extremely. Since health bars are visual, you can destroy the health bar of an enemy when they go off screen and create that health bar again when they come back on screen. And you can measure health of enemies via the sprite data extension which stores them to be able to remember them when recreating a health bar. These 2 optimization methods I need testing so any help would be greatly appreciated.

5 Likes

this small extension will be pretty helpful to see what actually improves your performance. Something to note is that im pretty sure sprites are laggy no matter how many colours they use and that registering sprite overlaps are especially laggy.

4 Likes

At any point in your game do you change to a scene? (For example, entering a new tile map with none of the past sprites or entering a menu)

2 Likes

The status bar idea is a good one, and the number of colors a sprite uses has no effect on how laggy it is, as each pixel is handled individually and which color that pixel is has no effect on the time it takes to render. Luke is right that sprite overlaps are laggy. You could implement your own overlaps that are based on a square around the sprite, which would cause a lot less lag. This is technically a built in feature, as there is a Sprite flag called something like “use rectangle hitboxes”, but it is not exposed in blocks. I have put it into a block in my JavaScript Extras extension. You could try that, but I think the extension adds a kinda insane amount of other stuff so just be prepared.

3 Likes

Good ideas hiding or destroying off-screen stuff can help, but invisibility alone might not change much since the sprite still exists in memory. Recreating health bars on return sounds more impactful though. Definitely worth testing on a heavier game to see real gains.

1 Like