Wednesday 14 March 2018

Modules with procedures

Experiences so far from a procedural C++ game project have been somewhat interesting. It's divided into modules which at the moment are Datatype, File, Function (for generic functions), Gui and the main module. Most of the code is in the Gui as you would expect. What I have learned is that procedural code seems to be "shorter" than writing classes, but it looks strangely messy. Maybe it's just that I don't quite know how to write clean looking procedural code.

Another interesting part is the Datatype class where I made a decision to use inheritance which may sound weird in this context. I'm using as much inheritance as I can, for example Rectangle class inherits from both Point and Size classes. And I have a feeling this is how I should have done this in the first place in my other projects as well. Using inheritance in this kind of limited context is easy and doesn't seem to have any problems this far. I had to name generic "Set" functions for Point to "Locate" and for Size "Resize" which is I guess better way to describe them. Using inheritance avoids repeating type of data and code for datatypes.

The graphics engine which is less than 300 lines of code in Gui can already display everything it needs: background tiles and letters with different colors. The next step could be the division of screen to three areas: gameview, message window and stats window.

Sunday 11 March 2018

My 7DRL plans

I think there is 7DRL season going on at the moment, I'm not sure. While I'm working on my main three projects it could be "fun" to write a smaller game. The problem you have with larger projects is that they become less and less manageable which is something that just happens. For a reason.

I do have a fun plan for this "7DRL" project in which I'm trying to write C++ with procedural style (also known as C) but with some classes where they are the most logical solution. The code is going to be more "modular" as more functions can be stacked in one file, rather than C++ style two files per class.

I wouldn't do this without a great idea for gameplay which I have had for couple of years. For simplicity I'm going to use ASCII graphics with SDL2, similar to what I have in Teemu. In fact I'm probably going to use Teemu's GUI (+fonts) and change it to procedural style.

Another reason I'm doing this is that I really need some time off from my large projects.