
I managed to fit a couple of hours in today for adding innkeepers and staying at an inn to The Narthenian Conspiracy. Since inns charge for a stay, I had to add gold to the game, and let the player collect gold from slain monsters. I also added a new sprite that will be used for merchants and innkeepers. It looks more like a wizard or a gnome, or maybe a gnome wizard, but that’s the extent of my art skills.
Innkeepers are their own class, and Merchants will be also. I could probably avoid some unnecessary code duplication by making NPC an abstract class, and subclassing the already existing NPCs, Merchants, and Innkeepers from it. I would probably have to turn the NPC vector associated with each map into a vector of pointers in order to make use of polymorphism. Whatever. I’ll deal with the consequences of my design choices for now and learn the lesson for later.
Staying at an inn fades the screen to black, and then fades back in to the usual display as a simple visual effect for going to sleep. I did this simply by drawing a black rectangle over the screen with alpha going from 0 to 255 and back. It probably goes a little to quickly as it is, so I may come back and tweak it to take longer later. Initially, the screen went straight to black; fading out and in wasn’t working. I realized that SDL3 ignores the alpha channel when drawing rectangles unless you call SDL_SetRenderDrawBlendMode on the renderer and set it to SDL_BLENDMODE_BLEND. This is probably also the case for earlier versions of SDL, but I have always copied portions of textures rather than drawn plain rectangles.
I wanted to put in a sound effect for sleeping at the inn, but haven’t created the sound yet. I may go with a different approach, and have the game play a “chiptune” arrangement of Brahm’s Lullaby during the whole interaction with the innkeeper, rather than using a sound effect just during the sleeping state. That’s something I’ll decide on soon: I’m currently learning my way around MilkyTracker in order to put together some background music for the game (it will ultimately be in .wav or .mp3 files; I don’t feel like implementing a reader/player for .mod files or pulling in too many external libraries for a relatively simple game). In any case, the decision need not be permanent if I don’t like how it turns out.
The game is becoming a little more playable with the ability to sleep at an inn and recover HP, so that going out and fighting and leveling up can continue. There is a lot to go with tweaking enemy stats, adding more enemies, adding items and spells, adding quests, etc., etc., etc. But little by little there is more to the game. While I’m working on the music, I probably need to also finish up the Carathusia town map, and put together some maps for the floors of the castle. Anyway, it’s easy to get overwhelmed thinking about everything that still needs to be done. More fun to focus on the enjoyment of seeing the little steps forward.
