I'm creating a space-invaders-type game for a school project, and my code seems to lag whenever the aliens move. I tried using clones to create 20+ aliens easily, but Snap! seems to lag really badly whenever there are more than three clones on screen. Similarly, when I create multiple alien sprites, the game also lags very badly. Attached is my movement code for the alien sprites:
Here is set speed:
Here is alienfunction:
And here is set health:
The way the code is formatted is pretty weird, but my functions have to stay the way they are because of project requirements.
the code you shared looks fine, i think the issue is elsewhere, possibly in the check health block. can you share the project?
it would probably help to figure out what part exactly of the movement causes it to slow down, by removing other blocks/sprites temporarily and testing it. is it still slow if you remove all the health related blocks from alienfunction? what if you get the aliens to not move at all, and just run whatever other code they have (if they have any)?