Wednesday, February 9, 2011

EventHandler, you stupid beast!

Pretty much all conversation between entities of my game is done through an event system. It helps me keeping the dependencies between subsystems in control (I like spaghetti, but I can't stand having it in my code editor), also I am in good shape if someday I decide to use more than one processor core at once.
The event system as it is right now is far from being sophisticated, in fact it is only 2 simple arrays of lists of eventhandlers (one array for normal events, one for recurring ones, one list for every event type).

Here's the event handler interface:
class EventHandler
        virtual void handleEvents(int eventType, 
            const EventDataList& events) =0;
The problem with that is because most handlers handle more than one event type, I have to do tedious event type checks in almost every EventHandler instance - and I know there must be a better way!  ...TEMPLATES TO THE RESCUE!!

So guess what I did try first - yes, I thought "Let's make handleEvents a template, use the event type as template parameter and specialize that in subclasses - means one function for every event type." -- utter fail! templates can only be used on non-virtual functions.

Time for plan B...      ...tomorrow!

Sunday, January 30, 2011

Building an arcade racing game

The story so far
So for the last months I've had some time to concentrate on personal projects, one of which is an arcade racing game playable on average computers and mobile devices. One thing I do if I don't have pressure in the form of deadlines (or actually not planning to release anything) is that I constantly trying to challenge myself and implement things I've never implemented before. This is the root of a never ending feature creep.

So to keep things a little bit more controlled I will use this blog to explain my reasoning behind what I'm implementing or planning to implement for this game.

What I already have
Not much to be honest. Design wise I have done a rough outline of the gameplay (which has some original elements), some concept sketches, discussing ideas with friends etc. nothing fancy. Let's just focus on the technical aspects for now:
  • everything is written in C++ without STL, no plans to use a scripting language yet
  • basic building blocks like containers, object database, event system are mostly done
  • work on an editor has started, but there is not much yet
  • done an hello world - like opengl es 2.0 renderer,
  • a simple vehicle physics simulation,
  • a simple mesh export script for blender and the accompanying c++ mesh loader
  • everything is built using scons
So what's next?
Right now I have some issues to with the event system which I need to fix. After that comes a camera system.

The next big step will be terrain rendering which I probably blog about.