Home > Projects > Game engine, part 1

Game engine, part 1

Edit 2: I think what’s really more evil in writing software is becoming religious and dependent on rules.  A well-balanced approach uses the right tool for the job, and static code lends itself to many benefits.  I didn’t see before that it is fairly simple to initialize a singleton with a mock implementation, but the whole thing still feels dirty.

Edit: The singleton pattern is pure evil.  I hope as long as I live I’m not forced to call out to code via a global static reference.  Or if I am, I hope to not have to pretend it’ll be modular and reusable, too.  Dependency injection is the new hotness.

I want to write a free game engine for C++, OOP, and OpenGL practice and fun.  I’ve had some experience in coding in XNA and in a commercial game engine, and I’ve got some ideas about how to do this easily and correctly.  So far, I’ve got a few lines of code implementing a scene graph and the beginnings of the GameMaster Singleton that will manage the game. The eventual goal is to get a nice open-source code base for people to build fun and fast games, and I will hopefully implement a game of my own.  There is a real lack of fighting games in open-source land, and I think I want to make one that’s better than those terrible mugen hacks.   I’m starting with the SFML library, which has some neat features implemented in a nice OOP way. I’ll also need to do some OpenGL coding, and maybe eventually some shaders (optimistic). Also looking at ASSIMP for 3d models handling.

The basic data structure is a scene graph. There’s a general node class that specific node types subclass in order to implement their specific methods.  I’m using a lot of virtual functions to let the nodes take care of themselves when possible and give a clean interface to controlling functions.  Also, it simplifies things like rotation and transformation. The transformation matrix on a node comes from multiplying all transformation matrices of parents.  I can easily propagate the results down the nodes and reuse my results for quick computation.  After trying to implement some basic functions, I decided I need an easy way to climb up the scene graph and have nodes notify each other of events. The issue arose when I contemplated node deletion. I’d have to delete it from memory and remove the entry from the parent node’s child list. I’d also have to delete all of its children. I wanted a nice generalized way, so I came up with a simple message passing queue stored in the GameMaster where objects can push a simple struct, which gives all control to something with a top-down view. Now I can have the GameMaster initiate a recursive search for nodes that need to be deleted, and it’ll be clean and easy. I think this idea will give advantages when implementing things like collision detection and networking.

Hopefully I can get some screenshots and videos up, that’s the fun part of this kind of project, but I have to learn OpenGL first 🙂

Categories: Projects
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: