By rescue86k

So my game is getting bigger, and keeping on top of lag is a high priority. Saying that I run the fps at 50, I never want it to go bellow a certain amount (such as 30, for a full blown battle, or 45 if only 2-3 objects/NPCs moving around).

Considering a big game, such as your own, you found arrays to be quite helpful. In my game, I have an enemy array (enemies) that checks hitTest() for each wall in the second array (walls) using a nested loop, presented in the base Avoider Game Tutorial. I assume you have completed that series, and you know what a nested loop is so I wont go into explaining it if you don’t mind.

I’m about to add a third array (allies) which will include the avatar in it. Problem with performance is this:

if currently you have enemies with nested walls, then you have that code being checked X times like so: 

enemies[# of arguments]  *  walls[# of arguments] = amount of hitTest checks.

Follow me?

Read the rest of this entry »