Sunday, 11 January 2026

Scene refactoring

New year begins with refactoring. This is an "old" problem, because for a longest time I did not understand how double buffering works in SDL until it became hardware "forced" in SDL3 that shows it. The way you are supposed to draw stuff is just draw everything for each frame. This doesn't work in Kaduria as expected, because there are stuff like menus which have their own drawing loop and they only draw their own window and text, nothing else.

To fix this you can do a lot of things, but one way is to create "scenes" which show everything for that screen. So when you are in a menu loop, it's showing the current scene on the background, then draws the menu window and text. Problem fixed, right. In most cases yes, but in some cases you need to figure out how drawing works inside the Scene class.

Then again, this refactoring is a minor problem when compared to lack of content. I still have to create most level themes, try to make the RPG system etc. I've been reluctant to even think about level themes, but they should not be that difficult. Most pieces needed for level themes are ready to use, although I'm not sure how to implement town type levels.