How to reduce lag

My game: https://flowlab.io/game/play/1339571
So I’ve noticed that my game has sudden lag spikes and just doesn’t really run well overall. I’ve done all I can to reduce the lag and get rid of unused code, but my game just doesn’t want to run smoothly. Are there any way for me to fix it (or reduce the lag to a playable amount)?

Hey @“Dihydrogen Monoxide”
First off, your game is super cool, I love the super straight forward and effective gameplay along with the cool artwork!

For me getting rid of the sound effects completely got rid of the lag, it was mainly the sound effects of lasers from what I could see. Getting rid of them should fix the lag problems seeing as how your logic isn’t quite ridiculously large enough to be the source of lag.

Good luck with your game!

Its The AI. Cause You Have So Many Ships Moving And Shooting At The Same Time All Over Your Game World It Causes Lag Cause The System Cant Keep Up With The All The AI Running At Once.

I Was Editting Your Game Of Course It Has Saving Off. But I Got Rid Of All The AI And It Was Really Smooth

To Reduce The Lag Either Get Rid Of The Ships Or Give Them A Proximity Detector, This Will Make It Where You Get In A Certain Range To Them They Start Moving And Shooting. When You Get Out Of Range The Stop. This Will Reduce The Lag Ten Fold

Thanks for the feedback! Seems like it’s a combination of AI and sound effects. I guess since there’s a lot of enemies that all bump, shoot, etc., they trigger all sorts of sound effects that lags the engine. I can’t get rid of ALL the sound effects as that would dramatically reduce the game’s quality, but I will try to regulate them and remove unneeded sounds.
As for the AI, I can’t get rid of them. I need the AI for the enemies to function, so I might just set a proximity sensor or something to limit their lag.
Using this feedback, I deployed a fix and it seemed to have solved most of the lag (spikes still happen, but more rarely and less severely).

@GrimProdutionZ

You Don’t Need To Use Caps On Every Word

XP

LOL But I Like To Stay Organized