2013/12/16

miniDooM: Squaring Things Out

Yes, I do love silly puns.



So, same drill as before. What we're seeing:
  • The Polygon is now a Square, and it is somewhat rotated, but it's edges are all wrong.
  • There are a set of red lines defining the coordinate axes.
  • A couple of red lines connect to each Doomie.
  • Each Doomie has a purplish circle around it.
What we're not seeing:
  • The Polygon is actually rotating on its own. The edges do not match up because they are not being updated correctly as the polygon rotates (they don't point to the next vertex in the polygon) and kind of lag behind as it turns. I'll be looking into it next.
  • Also, the problem I had in my previous update, with the polygon edges not matching the polygon, it has been fixed (it works before the polygon is rotated). Thing was that I was using a fast algorithm to calculate angles, instead of the standard (and more precise) Java method (atan2). The resulting loss of precision was really noticeable. I might need to tweak the algorithm.
  • The lines connecting to the Doomies actually keep connected to them as they move. They are simply a couple vectors that are recalculated each frame, mostly there to test that the vector calculation algorithm works correctly.
  • The purple circle is a mockup of what will end up being the collision area for the Doomies.
The big thing I've solved, though, is making the objects in the program have their own independent frame of reference.

What does that mean? Thing is that, when drawing to the screen in Java, screen coordinates are as follows: Coordinate (0,0) is the upper left corner, increases in the X coordinate moves to the right, and increases in the Y coordinate move down.

This was being an issue with the geometry calculations, as the math I use with them assumed the usual reference frame where increasing Y goes up, rather than down, and also where (0,0) is the center.

The solution has been creating an infrastructure to allow conversion from one frame of reference to the next. This also is very important for the final design of the game map, as I intend objects to be drawn relative to the map, not the screen! Not to mention that the camera needs to move on it's own too.

It's surely a mess, and horribly optimized, but I'm happy so far.


I really need to capture animated gifs of my progress... But since I work exclusively under Ubuntu, the existing tools for animated screen captures are somewhat daunting...

No comments:

Post a Comment