So, some of you may have noticed that the game gets slow when there's too many enemies on the screen. Ever since day 1, I've been convinced that the problem lies in the code. In particular, I rely heavily on the hitTest() command, which known to be processor intensive. In order to minimize this, I nest the hitTests under layers of if() statements. The theory is that an if() statement is quick, while a hitTest() is not. And if I can get an if() statement to flag false, then I can skip the hitTest() entirely. Okay, maybe I'm not explaining it very well, but when it was explained to me it sounded solid enough. haha.
So, did all that. Actually been doing it since my first game, and I do think it helps. But it's not enough. While I was away, Renara (LoK forums) posted a bit about optimizing code. And that really got me looking at my code again. Although I knew it was bad form, I often had 2 or 3 onClipEvent() loops running simultaneously, as it was just easier for me to code. So I went back & fixed that. And once again, it helped, but it's not the miracle fix I was hoping for.
What it did fix however is that now when I'm fighting several enemies, if I scroll the screen to hide most of them, the game suddenly speeds back up again. This made me start thinking that maybe this isn't entirely a code problem after all. Some of y'all had requested a 'quality' button, which was pretty common in older Flash games. I really hadn't even considered it, but after digging some I found the commands & figured I'd give it a whirl. And sure enough, with the video quality set to low, the game now runs great. And WOW does it look like utter shit. Enjoy the picture below, it reminds me of like an old 8 bit game gone horribly wrong.
So for those of you who prefer speed, there's going to be a quality button. I'm not real happy with that fix though, so I'm going to play with the sprites that make up the monsters, and see if further optimizing their shapes can speed the game up some more.