kwoolter 🐒 ©️ 2020
This game is a rogue-like game that uses the libtcod library and is loosely based on the python rogue-like tutorial.
| 
 | 
 | 
| 
 | 
 | 
F1help on controls available from current screenPage UpandPage Down- change font size
Game Ready Screen
Ncreate a new characterENTERorSPACEto start the gameEscquit the game
Create New Character Screen
Nchange player's nameCchange player's classRchange player's raceENTERorSPACEconfirm race/class selectionEscexit screen
Game Playing Screen
- Arrow keys - move and attack enemy
 1-4- use spell in spell book slotCtrlattack current target with equipped weaponGorSPACEget an itemQorUuse item currently equipped in Item slotXexamine item on floorZskip turnCcharacter screenRinventory screenJjournal screenKspell bookENTERorVtravel on stairsEscpause game
Game Paused Screen
Qquit the gameEsccontinue playing game
Inventory Screen
- Arrow keys or 
WASDchange selected item Eequip an itemQorUuse an itemXexamine an itemFdrop an itemEscorRexit screen
Spellbook Screen
- UP/DOWN Arrow keys or 
WSchange selected spell - LEFT/RIGHT Arrow keys or 
ADchange selected spell level filter Mmemorise/forget spellLlearn/unlearn spellEscorKexit screen
Character Screen
- Arrow keys or 
WSchange selected ability L,EorSPACElevel-upUupgrade selected ability using Ability PointsEscexit screen
Shop Screen
EorBswitch to Buy tabQorVswitch to Sell tab- Up and down arrow keys or 
WandS- change selected item ENTERorSPACEbuy/sell the selected item- Left and Right arrow keys or 
AandD- change item category in Buy tab Escexit screen
Game Over Screen
ENTER- continue to Game Ready Screen
- http://rogueliketutorials.com/about/
 - http://rogueliketutorials.com
 - http://rogueliketutorials.com/tutorials/tcod/v2/
 
Features:
- DnD-like classes, abilities, monsters and combat rules
 - DnD-like armour, melee weapons, ranged weapons and other items
 - Dnd-like spells and spellbook
 - DnD-like ability checks
 - XP and Leveling-up
 - Random dungeon floor generation with more rooms per floor as you get deeper
 - Field of View (FoV) lighting
 - "Fog of War" unexplored map
 - Random enemies in each room that scale as you go deeper
 - Random items scattered across the floor with probability governed by game rules
 - Potions and Scrolls have randomised effects
 - Random colour palettes and random room and dungeon level names
 - Random Lore generation
 - Inventory and Shop features
 - Perma-death
 
Overview:
roguelikemodel- modules containing the classes for the game, floors, entities, etc.view- modules containing the classes for all of the viewscontroller- main control loop
tutorialdirectory - how I started out following the python tutorial
model.py- main module that containsModel,Floor,Room,Tunnelclassesentity_factory.py- containsEntity,EntityFactory,Player,Fighter,Inventoryclassescombat.py- containsCombatEquipment,CombatEquipmentFactory,CombatClass,CombatClassFactoryclassesspells.py- spells and spellbook related classesevents.py- all of the event names used in the gamethemes.py- module for managing colour themes and random name generationdatadirectory - data files for the gameentities.csv- all of the game objects and their propertiescombat_equipment.csv- more properties for entities that are armour or weaponscombat_classes.csv- the different types of fighter classes and their abilitiesgame_parameters.csv- the rules of how the game scales in difficultyability_checks.csv- which items can you perform an ability check on and what are the outcomes for success and failurethemesdirectory - data files for colour themes and random name generationfloor_palettes.csv- colour palettes for different themesroom_palettes.csv- room colours for different themesrogue_history.cfg- config file for name generation usinglibtcod.namegen_generate()functionalityroom_names.csv- not used anymore as switch to random name generation usinglibtcodlibrary
view.py- main module that containsMainFrame,FloorViewand other UI View related classesview_utils.py- utility classes for drawing stuff on a consolefontsdirectory - different font files that can be used withlibtcodscreenshotsdirectory - screenshots of the game in action
controller.py- main game loop, keyboard event handling, orchestration of game states and UI states
- Python 3
 tcod- creating and writing to consoles, keyboard events, colours, field of view (FOV) calculations, random name generation, etc.numpy- floor maps and properties. Also used bytcodlibrary for FOV calculationspandas- used for loading incsvfiles that hold the game data e.g. entities, combat items, etc.pygame- only used for theRectclass
The Entity objects that appear in the game have a count and probability metric defined either for the current Floor or for each individual Room on the Floor.
For example, what is the maximum number of rats that you want to add to a room and what is the probability of each rat successfully being added?  You may want at most 3 rats per room each with a 50% probability.
So in the game, for a given metric y you can specify how it is calculated using this formula:
y = a*x + b + (x//d) * ad
Where x is the dungeon level that you are currently on and a, b, d and ad are parameters defined for each metric.
So breaking this up, y = a*x + b is the simple formula for any straight line plotted on an xy axis. a represents
the slope of the line and b is the y intercept.  However, you may want an increasing number of rats at lower dungeon
levels but no rats beyond level 10.  To support this you can add (or subtract) x DIV d multiplied by a different slope.
So if you want no rats to appear after level 10 you can specific (x DIV 10) * -100.
Furthermore, you can constrain y by specifying minimum and maximum values.
This means you can cap the number of rats per room at say 4 but at a minimum always attempt to add 1.
Pulling all of this together you end up with the following lines of code to calculate y:
        # Calculate y = a*x + b + (x div d)*ad applying min and max constraints
        result = a*xvalue + b
        result += (ad * (xvalue//d))
        result = min(max(result, min_), max_)
An example visualisation of this is shown in the graph below where the orange line is y = ax + b,
the blue line is (x div d) * ad and the grey line is y which is the sum of these two lines with a maximum and minimum applied (4 and 0 respectively).
Using this basic concept you can create interesting curves for count and probability for each Entity in the game.
This file defines the count and probability for each entity that you want to appear in the game's rooms or floors.
Columns:
Entity- the name of the entity you want to define a metric for e.g.RatMetric- which metric are you defining e.g.CountorProbability?Scope- what scope is the metric for e.g.RoomorFloor?x- what is the name of the variable that you want to substitute asxinto the model - typicallyLevela- slopeb- y interceptd- x DIV valuead- x DIV value slopemin- the minimum value ofymax- the maximum value ofyTemplate- use a template instead of a,b,d,ad values
Use templates for when you want to share Count or Probability curves across multiple types of Entity
Each Entity in the game needs to be defined as a row in this file.
Columns:
Name- the short name of theEntityused in other property files e.g.combat_equipment.csvDescription- a description of theEntityused when it is displayed in text messagesChar- the character used to represent theEntityon the gameFloorViewCategory- group entities together by categoryFG- foreground colourBG- background colourZorder- order of display in descending order i.e. 0 is draw lastIsTransparent- does light shine through it?IsWalkable- can you walk onto the same tile as it?IsInteractable- can you interact with it?IsCollectable- can you pick it up and put it in your inventory?IsStackable- can you stack many of the same item?IsEquippable- can you equip it as a weapon or armour?IsCheckable- can the player perform an ability check on it?IsEnemy- is it an enemy of thePlayer?Value- how much is it worth?
The process for adding new types of Entity to the game is as follows:-
- Add a new row to 
entities.csv - Add 2 new rows to 
game_parameters.csv; one for generatingCountand one forProbabilitymetrics - If the new 
Entityis a piece ofCombatEquipmentthen add a new row tocombat_equipment.csv - If you can ability check the 
Entitythen add a new row toability_checks.csv