Wednesday 13 October 2021

The Object Class

I'm working on a new project which is going to be more like a traditional role-playing game. The nice thing about this is that I'm starting from zero and this time I'm able to think about how to implement things in a simple way. The programming language is still going to be C++, but I try to avoid complex classes and also use procedural style for "action" code.

I was reading about game objects and noticed an interesting comment in which the idea of generic "object" base class should be removed. With that you should consider different game objects as their own base classes - in this case movables, items and creatures. This idea is something I want to try, because it doesn't sound that bad and it will certainly remove some problems I've had with that type of implementation in both Teemu and Kaduria which are complexity and large amount of virtual functions.

If it does work I've been "wrong" about object base class for a long time. However object base class does work better (I guess) in situations where you need to write generic routines for game objects, because the virtual system can decide what to do with some type of object and you only need the base class for parameters etc. Then again, routines for creatures and items tend to be different, so it's interesting to see what happens.

No comments: