I've been working on a little game engine in my spare time this summer. It's a 2D game project that I've been thinking about called Symmetris. It's a Tetris-style game where pieces appear and you have to make them go away -- but in this case, you make them disappear by sticking them together and making symmetrical shapes.

Anyway, I'm writing it in Python, and I've learned a lot about game engines in the process. After my work on Swordplay and Diplomacy, game engines are becoming more and more repetitive, and I'm discovering new things that I have to deal with at every turn.

Examples. Okay. Uhm, objects in the world. You're gonna have objects that sit around in the world, and objects that are attached to some other object, and so forth. Sometimes you have layers upon layers of objects! When your graphics loop gets around to rendering these, it just wants to see a list of triangles separated by matrix pushes and pops. And, if you can avoid it, you don't want to be telling objects to draw themselves -- you want to get that list for yourself. On the other hand, on the physics side, you probably only want to deal with top-level objects, and let the lower level objects automatically "get moved" as you move their parents. Anyway, for this problem, I'm discovering that trees are a fun and useful way of representing this. In Swordplay, we ended up embedding the tree structure into our objects themselves, which was not ideal (because we were going around referencing coordinate frames in weird places). Instead, I recommend a separate tree structure; your 'world' object has a list of several children, and you simply do your physics on these; but each child may have a graphical representation, and you should write a traverser that glPushes and pops the appropriate matrix at each level of traversal.

One thing I'm still learning is that physics is hard. I'm doing 2D rigid body physics in Symmetris and it's really not easy! What I've got is pretty sophisticated, but it's incomplete. I'm doing everything with convex polygons, and I have point containment and collision detection working great. I don't, however, have any sort of collision response, and that's where I'm a little stuck. I have several ideas, but none of them are great.

anyway, I just wanted to post something so my blog doesn't look dead. Future topics: Swordplay & Diplomacy, cs141, california, mexico...