War in Space Day 19

I finished the “transporting” logic which checks if objects have left the screen completely and, if so, move them to the other side of the screen. Therefore, objects can now endlessly leave the screen on one side and appear on the other side.

I also implemented a function which determines which edges and vertices of a 2D AABB another AABB is intersecting. The idea is that objects which are partly off the screen are rendered more than once in different places. Therefore, to correctly do collision detection, we need to not only check the intersections at the current position, but also at those positions where the object’s clones are rendered. The following diagram shows such a situation. The ship is partially off the screen and therefore also rendered at the other side of the screen. The projectile is intersecting the ship’s mirror image but not the ship at the original position. Therefore, if collision detection was only carried out with the ship at its true position, the collision would not be detected.


Mesh collision detection

Even though the foundations for collision detection are now laid, there is one flaw remaining: My ships are still represented by single triangles. What I want to do in the last phase of making the game is making it a bit more aesthetically pleasing, especially by exchanging the triangles by some models. Now, the problem would be to do collision detection. Since I think I would have to neglect some other things if I implemented collision detection myself, I’ll give JigLibX a chance for the collision detection.

Leave a Reply

Your email address will not be published.