Monday, January 07, 2008

Hitting the right spot

Well, I spent the last few hours working on implementing bounding box collision detection. I would have gotten farther today, but I spent a lot of time looking for a simple bug in the wrong places, which sometimes happens. Essentially for the game barricade, I have it setup so that I can see the bounding boxes in debug mode for the game. Or, at least that was what I was trying to do. All I could get it to do was draw three boxes in the center of the screen though, one for each of the different sizes of blocks in the game. So, I went hunting to see if I could find the problem. I thought maybe I wasn't drawing it right, and tried different variations of using offsets from the quads the sprites are drawn on. It didn't work.

I then realized, after setting some break points, that the data stored in the structures for the sprites bounding boxes was still set to zero. You see, I had placed setting the bounding boxes translations in the same function that generated the sizes of the blocks. This wouldn't have been a problem, except that the bounding boxes are determined by an offset based on the dimensions of the textures and the translations of the quads for the sprites themselves. So, of course the size of the blocks would need to be generated before the placement of the blocks, so the data wasn't getting set correctly. I finally figured this out after looking around for a while. Simple, simple things can cause such chaos in a system.

So, I ended up re-building the system within it's own function and had it updated after the placement of every block. This worked out great. Here's a picture of it in action.





Clicky for bigger View


Next up tomorrow will be writing the actual collision detection for block to block collision. Then it will be on to finishing the bullets class, followed by bullet to block collision. Then bot to powerup collision.

After that the only things left to do will be to code the powerup effects, the scoring system, add sound effects, and the demo will be finished. I'm aiming to get this done by the end of the month.

No comments: