Posted May 30, 2022 by fljohnson3
#debugging #level
As you likely figured from the title, adding a second level exposed a boatload of not-so smart design and implementation moves.
For starters, placing a dozen enemies on the second level revealed that having all enemies do pathfinding in the same frame is a recipe for poor frame rate. I answered this by tracking the set of enemies and staggering their pathfinding. This way, only one enemy per frame is doing that expensive operation.
Another "DOH!" came in carrying the set of weapons and ammo from one level to the next. In order to keep the weapons from disappearing when a new level was loaded, I had to, for each weapon
Finally, I hadn't properly dealt with the mouse handling, meaning that the user had to rely on the computer's window-management system to close the program. I answered this by toggling the "cursor lock" setting with the Escape key