Boy, do I have some good bug hunt stories for you guys today, along with some neat new screens showing off some cool new features I added.
The Great Bug Hunt!
So yesterday night, I was pretty pissed off, because a couple really annoying bugs appeared out of nowhere, with no probable cause in sight. Last night I was really working to get the Light AAA functional to the point where they could fight and would die if shot too much. So I decide to add a flak unit to the level that the game loads on startup, so that I wouldn't have to add one everytime I wanted to test the system (remember this step, its the source of the bug). Anyways, I did some other stuff before I actually started playing the new level. Well, all of a sudden, 2 weapons are being spawned everytime I shoot... WTF I think to myself, I didn't even touch the weapons code. So I sit for about an hour messing with the code and trying to figure out why the hell 2 weapons are firing whenever I shoot. I even hardcoded the airplane to only be able to shoot once, but 2 things kept getting fired. I was convinced I wasn't clearing the "stuff to spawn" queue, and the same thing was getting spawned more than once. Turns out, it had nothing to do with the weapons, it had to do with.... me saving the level, read on... Well, eventually I got pissed off and started flying around and blowing shit up, then I noticed that the plane looked wierd.. no wait! There's two planes there! And they're overlapping! Then it hit me, and I looked at the level startup code. Turns out, that a long time ago, before I added the Load/Save routines, I added a bit of code that loads up a plane when the level loads, so that I could fly around with it, because the initial level at that time didn't have a plane to load. Well, when I saved the level to keep the flak there, it saved that plane in its starting position, and when I started the game again, it loaded the new plane, and it created the hardcoded plane and placed it right over the new one, so I couldn't tell there were two planes there, and whenever I tried to fire the weapon, both planes spawned their own object. Anyways, I removed that hardcoded plane loading, and voila! fixed. If I hadn't noticed that 1 pixel offset on the airplane I would probably still be trying to figure out why the hell that damn queue wouldn't clear[grin]
This was a nice little addition that helped me find the other bug that had been bothering me. Once I enable collision in the bullets, the game would crash on me about 10 seconds into the game. I disabled collision and started working on some other features (including the health bars). A few hours later I came back and reenabled collision to see if I could figure out why it kept crashing. Once I entered the game, I quickly discovered what had been happening. The bullets fired from the flak guns was colliding with the flak gun itself, and would damage the flak. After about 5 seconds of firing, the flak would eventually kill itself, and effectively delete itself. This is all good if everything is happening the way it should, but in this case, the bullet still had some work to do, and it's collision reference, had become a null pointer.. .CRASH!!!! Anyways, I added an allegiance system to the objects, which stops objects of the same "allegiance" from damaging eachother.
This was a quick addition that took about 10 minutes, but adds quite a bit of coolness to the game. Now, instead of just flaming chunks of debris, an explosion animation is played as well, resulting in a much more gratifying experience for the exploder (but not so much for the explodee). Anyways, you guys can see the explosions and the health bars in the screen below:
Anyways, I'm feeling a bit more on-track now that I've solved those bugs, so I'm still hoping to have a demo out soon, but until then, you'll have to imagine[wink] Peace Out!