Thursday 7 December 2017

Feature creator

For basic cave level I want to try something new with rooms and corridors. I don't know if this routine has a specific name, but I have seen it before. It's filling the level by searching for next free place for a feature which can be something like room or corridor, or whatever. I guess features can also make branches so in fact this is somewhat like a maze algorithm, just with larger building blocks.

I don't actually need anything new for this algorithm, only the sequence of creation is something that has to be arranged using building bots like the maze routine does.

I think this is going to be the last big algorithm for level themes, then there are some static themes that need some work. Even I have tried to keep things simple it's taking quite a long time to finish 1.3, but I guess this is roguelike development.

Friday 1 December 2017

Procedures in C++

This is something I must have been mentioned before, but let's recall it. C++ is mainly object-oriented but I've realized that procedures work in situations where objects are not needed. Usually small generic routines and algorithms are good as procedures, because they follow the rule of not changing any dynamic data (objects).

It's ok to create classes for small tasks, but in some cases it becomes a bit clumsy when you need to create instances for extremely small things. Also, procedures tend to relieve the problem in classes when you create repeating code for each class, because inheriting is often not possible to do with any kind of working logic. This inability to use effective inheritance is one of the biggest problems in OOP at least for me. It's not easy to plan good class hierarchies that are safe from difficult changes later.

There is a place and time for procedures, but I think they are extremely bad at handling dynamic data, because then you easily lose ownership mechanism which is one of the strong features of OOP.