Saturday, 21 August 2010

Load and save

Now when Actor class is refactored out I can continue writing save and load routines. Most of object types already can save and load, but some of them still missing. I'm using my world famous Tar_Ball system (developed for Teemu) in save/load. It's not beautiful, but it gets the job done.

The big question remains whether to save per level or keep all levels in memory. Kaduria is going to be a graphical roguelike for modern computers which can handle the memory requirements, but then again it could be cool to keep memory use low. Levels are active one at a time so there would be no need to store all levels at once anyway. Saving a level for first time is revealing, it can be estimated there how much memory one level spends.

Saturday, 7 August 2010

Game object rewrite

Placing a wrapper class Actor between the base and derived classes was not that clever after all. I wanted to give Opener and Container ability to some object types through Actor, but as usual when something may seem like a good solution it turns out to have unexpected problems.

The problem with Actor was that it didn't know about derived classes. In actions like opening something there is more involved than just the component data of Opener class. Different openers act different ways. So the rewrite is about removing Actor and moving Opener and Container classes as components of derived objects. With that approach you can't avoid copying code of virtual functions. Good thing is that the code is short, because of functionality of component classes. And more importantly you get to write individual opening code for each object type, checking out things that belong to the derived class.

Like for instance there are doors and sewers, both openers. But sewer is really a different thing, because the lid can be missing! So, using virtual Open() for both door and sewer have same type of code for Opener section, but there are special things that only certain object types have. Also, when you have virtual Open() it's going to be easier to handle, because you can use the base class handle for opening action.

I think the cost of using virtual functions is not that bad when compared to difficulties that follow with extra class in middle of the class hierarchy. I believe the rewrite can be done during this weekend, so it's not going be that hard, even though it is kind of a big change to the game object system.