2013/07/10

The Wonders of Re-Inventing the Wheel

So I've been working into meeting my next deadline. My usual methodology is to focus on the next piece of code that needs to work, and take it from there... That methodology takes me to strange places.

It first began while perfecting the collision system for the game. I realized the collision calculations could be generalized into a 2d vector class. Which I implemented. But then realized I could split the location information into it's own 2d point class which handled the related distance/location based calculations. And then I though "why don't I take all those mathy calculations and move them to a static library so I can tweak them outside the class implementations". Which in turn lead me to organizing all those static methods into appropriate namespaces...

Suddenly I though "Hey! I'm losing focus!" so I went back to finalizing the collision system. And realized I needed to also check collisions with rectangular areas. But as I worked on the simple formulas, it turned out I needed also to be able to rotate said areas. So they were split into Bounding Boxes and Rectangles. And as I worked on the Rectangle I realized they were, in essence, and specific case of a Polygon, so the whole class was renamed Polygon and a new class inheriting from that one with a limited number of edges was created...

And then I pulled back, realized I had skipped dinner in my excitement, and was too late in the night to cook without bothering my neighbours.

So, in conclusion, I might end up creating my own 2d polygon library.

This, I think, is a good thing. I was considering using an existing library (straigthedge) that provides most of the functionality I need, but as I'm still learning many of the concepts involved, doing it myself, even if badly, is really helping me grasp many notions, which can only help when eventually resorting to using third party libraries.

So I'm mostly venting because despite churning out lots of code, the game is still at roughly the same point it was before, only with a more solid foundation.

No comments:

Post a Comment