I built my first Tower Defence game, and it works fine for the first little bit, but then, as you add more than 3 towers, and they start shooting, it gets extremely slow. I checked the Task Manager and it's taking up 28,000 K of memory. Don't you think that's a bit too much? There's no complicated processing or anything, everything is stored in a small structure. Could it be the images? I have no idea. What's wrong?!! None of my other games use even close to that much. It really shouldn't use that much memory, when I look at it. I also notice that 100% CPU is being used. How do I change the program to run efficiently?
Last edited by minitech; Jul 23rd, 2009 at 09:05 PM.
I've merged more loops for efficiency, and it's faster now, but still... slow. Now, I also get an ArgumentOutOfRangeException (index out of bounds), and it says that the source line is Me.Invoke(tmr) inside Timer_Timer(). I'm assuming that it's coming from something the delegate calls, probably MoveAllX() where it does operations with loops, collections, indexes, etc. That would happen if I remove the last item in the list and then reference it by index, correct? I just can't find a spot where that happens. I'm also still stuck with the "slow" problem. Help, please!
Changes are reflected in the updated Form1.vb attachment.