Sunday, June 15, 2008

Extinctathon: enemy types and collision bugs


Now that the level loading is about halfway where I want it to be (it's independently loading lists of Blocks and Species), I need to do some serious work on the collision detection algorithms. I'll go into more detail in future posts, but here are the basic problems.

  • I need to implement per-pixel collision detection. This is most noticeablely an issue with the Snakeocat at the end, which, by virtue of the size of its bounding box, floats in the air a good deal more than the other enemies
  • I need to do a much better job of processing collisions with enemies once they occur. The player dies in a handful of situations where he shouldn't. Right now, the player dies if he collides with the bottom 3/4 of the enemy. If the player is falling too fast, or the enemy is rising too fast, even when the player hits the enemy from above he dies. What needs to be done is to extract the player from the enemy and then determine if the player was on top, to the side, or underneath.
  • Similar fixes need to be done with regards to collisions with blocks. There is a rare bug when the player is between two blocks spaced exactly the width of the player apart that can cause some unusual behavior.
  • I need to optimize the hell out of it. I deployed to my XBox for the first time this weekend, and anything more than 6 enemies on screen KILLS the performance. We're talking 1 or 2 frames per second. My basic algorithm is as naive as it gets (literally everything is tested with everything, an O(n^2) algorithm), and I need to fix it as soon as possible. It does fine with a couple hundred enemies on my computer, but, of course, that's a lot faster (with certain kinds of operations).
  • In addition to optimizing the broad phase of the collision detection, i.e. deciding what should be tested against what, I need to do some serious optimizations on the collision detection itself. I have not yet decided how best to handle this.
  • And, finally, I need to make it so that when enemies die by falling off the screen they don't give you points.
That's it for now. I was kind of lazy today and ended up just making a new enemy (the af0rementioned Snakeocat). I'll get to work on the serious stuff tomorrow.

No comments: