Saturday, August 4, 2012

Infiltrator Part 32 - Boon Town Shredders

This session was rather fun for me. It saw the completion of several tasks that seemed very daunting. Some of them were just extra's that I managed to fit in within the session time even though I had already met my goals. Put simply: this session was an epic boon.

Let's start out with the Shredders. Even before I started designing the Shredder AI, I knew it was going to be a big job. The whole thing seemed-as previously stated-rather daunting, but after a good number of hours scribbling scenarios on a whiteboard and taking notes I was able to come up with the four modes I mentioned in an earlier Infiltrator post.  These were a bit of a challenge to implement, not to mention the difficulty of coming up with the modes and rules in the first place, but I eventually made it happen. The funny thing is that I did all of this first in order to avoid the next item on my list.

You see, I had long been delaying the addition of ray-casting to my engine. I have a history with ray-casting and have for a long time seen it as being complex and overwhelming. Turns out, that's a bunch of nonsense. Well, okay, a bunch of nonsense when you're just using Box2D's built in ray-casting, but still... It was a cinch. More kudos to Erin Cotto for making Box2D super awesome. Adding ray-casting to the Shredder's AI and setting up a few extra rules about when to switch to which mode was amusing and easy once I had the core interface setup. After that, I turned  my eyes on some stability issues in order to make sure I had the best version 0.0.7 as possible.

There were three different times when Infiltrator was crashing. One of them during initialization, one whenever the user selected to continue after dying, and one during a different part of initialization. During each of these times, there was about a 20% chance of a crash. This had been going on for so long that I had actually gotten kind of used to it, but I knew such frequency of crashing was unacceptable for any game intended for release. After quite a bit of debugging I was able to trace them all back to the same core issue which was easy to fix but hard to find.

You see, the level files work in a special way. A level file specifies how many of which types of objects are in the level and then lists them. The level editor is supposed to calculate these things automatically, but it was somehow turning out corrupt level files that asked for more objects than it listed. I quickly learned that this was because it wasn't taking the erasure of objects into account and thus thinking it needed to make space for objects that had long since been deleted when it was writing the level file. My file parser code was even returning an error that could have prevented this from happening, but my level reader wasn't doing anything with it. You can bet that I'll be a lot more careful to put in failsafe code and error checking from now on.

So through the fun and tediousness I arrived at the end of my list and finished version 0.0.7. I've got some moderately challenging and engaging gameplay going on here, much more than I expected to reach when I started this project. Time to get to work on that menu and those camera modes.


No comments:

Post a Comment