Wednesday, May 9, 2012

Infiltrator - Part 21 - Optimizing and Upgrading

Well a-whoop-dee-do for me. My game got to the point where it needed optimized. Sometimes optimization is just going through and replacing place-holder code that does the ridiculously stupid with more neat and tidy code that is easier on the CPU, but sometimes it's a bunch of tedious busywork as you try to pinpoint bottle-necks and come up with convoluted ways to circumvent the need for using up vital processing time.

The best trick was to tweak the enemy pathfinding system so that they take turns re-calculating their paths. Every 20 milliseconds(or so), the next enemy in line gets their path updated. This works out really well, and has actually eliminated 90% of the sudden and random framerate nap issues I've been dealing with.

But I've done more than adding necessary optimizations. I'm just going to run through a bunch of the other upgrades briefly.

I've added ability to remove placed objects to the level editor, because I got sick of the inability to erase. With that done, level design can now be significantly easier and higher quality since it takes less time. I've also fixed a bug where shots from dead or off-screen enemies wouldn't be processed, which used to allow cheating on both sides since shots could end up passing through the player or walls. There was also an interesting gameplay problem where enemies could often shoot you on the exact same frame they came on-screen, which was quite a bit unfair and un-realistic. This was the result of the time counter that was used to time how often they shot was still ticking after they left the screen. I solved this by re-setting the shot timing when they came back on screen, giving the player a moment to perceive them and giving the enemies an imaginary moment to line up their shot.

I'm sorry if I couldn't go much more in detail this time around. My head is still spinning from the aftershock of last week, which was completely crazy. Still, I hope you enjoyed reading up one my game's progress. ;)


No comments:

Post a Comment