r/roguelikedev • Robinson • Jul 09 '19

RoguelikeDev Does The Complete Roguelike Tutorial - Week 4

This week we wrap up combat and start working on the user interface.

Part 6 - Doing (and taking) some damage

The last part of this tutorial set us up for combat, so now it’s time to actually implement it.

Part 7 - Creating the Interface

Our game is looking more and more playable by the chapter, but before we move forward with the gameplay, we ought to take a moment to focus on how the project looks.

Of course, we also have FAQ Friday posts that relate to this week's material.

Feel free to work out any problems, brainstorm ideas, share progress and and as usual enjoy tangential chatting. :)

29 Upvotes

54 comments sorted by

View all comments

Show parent comment

2

u/itsnotxhad Jul 09 '19

Right, I actually finished the tutorial in the first week and took the same approach of “don’t change anything until I know what the finished product looks like.” What I mean by my issue is that GameMap hardcodes nearly everything that is used to define a floor. That one class does too much for my tastes; it includes monster definitions, item definitions, drop tables, room generation, as well as the logic for moving between individual floors and possibly other stuff I’m forgetting. Adding nearly any content to the game requires “factor some stuff out of GameMap” as a first step.

What if I want to exclude monsters from a certain floor, or have an oddball treasure/enemy distribution for one floor only, or even have certain floors be a “boss chamber” with little exploration and a lot of enemies in one room? Currently that would require updating several dictionaries and branching if statements scattered throughout the class, and I’m not even sure I’d be getting it right.

I’ve already created a monsters.py and items.py to address this in part, and now I’m thinking the next step may be dungeon_floor.py

1

u/itsnotxhad Jul 11 '19

UPDATE: I have now rewritten GameMap to the point that I deleted the original class name to make sure there's not any code left accidentally calling it. Some stuff that led me to this decision:

  • entities is passed around from module to module and doesn't really "live" anywhere even though nearly everything both (a) mutates the list and (b) also takes game_map as a parameter. I ended up making it an instance variable of a class instead of an obfuscated global variable.
  • There are constants in initialize_game.py that probably shouldn't be hardcoded for every floor when the game loads. But that's okay because those constants are never actually used; they were also hardcoded in GameMap, with different values. Other times, GameMap would ask for some of these constants in a method call, even though they're game-wide constants and any logic that would involve changing them would necessarily mean changes to GameMap.

It's not final until I actually finish writing it, but it's looking like I'm going to have a World class for the gameworld in general and a DungeonFloor class for individual floors. Then go rewrite Stairs so that instead of just storing an integer it contains the logic of transitioning to the next room. Then DungeonFloor can generate its own Stairs which generates the next DungeonFloor while World keeps track of where we currently are.