kwoolter 🐒 ©️ 2020
This game is a rogue-like game that uses the libtcod
library and is loosely based on the python rogue-like tutorial.
F1
help on controls available from current screenPage Up
andPage Down
- change font size
Game Ready Screen
N
create a new characterENTER
orSPACE
to start the gameEsc
quit the game
Create New Character Screen
N
change player's nameC
change player's classR
change player's raceENTER
orSPACE
confirm race/class selectionEsc
exit screen
Game Playing Screen
- Arrow keys - move and attack enemy
1
-4
- use spell in spell book slotCtrl
attack current target with equipped weaponG
orSPACE
get an itemQ
orU
use item currently equipped in Item slotX
examine item on floorZ
skip turnC
character screenR
inventory screenJ
journal screenK
spell bookENTER
orV
travel on stairsEsc
pause game
Game Paused Screen
Q
quit the gameEsc
continue playing game
Inventory Screen
- Arrow keys or
WASD
change selected item E
equip an itemQ
orU
use an itemX
examine an itemF
drop an itemEsc
orR
exit screen
Spellbook Screen
- UP/DOWN Arrow keys or
WS
change selected spell - LEFT/RIGHT Arrow keys or
AD
change selected spell level filter M
memorise/forget spellL
learn/unlearn spellEsc
orK
exit screen
Character Screen
- Arrow keys or
WS
change selected ability L
,E
orSPACE
level-upU
upgrade selected ability using Ability PointsEsc
exit screen
Shop Screen
E
orB
switch to Buy tabQ
orV
switch to Sell tab- Up and down arrow keys or
W
andS
- change selected item ENTER
orSPACE
buy/sell the selected item- Left and Right arrow keys or
A
andD
- change item category in Buy tab Esc
exit 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:
roguelike
model
- modules containing the classes for the game, floors, entities, etc.view
- modules containing the classes for all of the viewscontroller
- main control loop
tutorial
directory - how I started out following the python tutorial
model.py
- main module that containsModel
,Floor
,Room
,Tunnel
classesentity_factory.py
- containsEntity
,EntityFactory
,Player
,Fighter
,Inventory
classescombat.py
- containsCombatEquipment
,CombatEquipmentFactory
,CombatClass
,CombatClassFactory
classesspells.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 generationdata
directory - 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 failurethemes
directory - 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 usinglibtcod
library
view.py
- main module that containsMainFrame
,FloorView
and other UI View related classesview_utils.py
- utility classes for drawing stuff on a consolefonts
directory - different font files that can be used withlibtcod
screenshots
directory - 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 bytcod
library for FOV calculationspandas
- used for loading incsv
files that hold the game data e.g. entities, combat items, etc.pygame
- only used for theRect
class
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.Rat
Metric
- which metric are you defining e.g.Count
orProbability
?Scope
- what scope is the metric for e.g.Room
orFloor
?x
- what is the name of the variable that you want to substitute asx
into the model - typicallyLevel
a
- slopeb
- y interceptd
- x DIV valuead
- x DIV value slopemin
- the minimum value ofy
max
- the maximum value ofy
Template
- 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 theEntity
used in other property files e.g.combat_equipment.csv
Description
- a description of theEntity
used when it is displayed in text messagesChar
- the character used to represent theEntity
on the gameFloorView
Category
- 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 generatingCount
and one forProbability
metrics - If the new
Entity
is a piece ofCombatEquipment
then add a new row tocombat_equipment.csv
- If you can ability check the
Entity
then add a new row toability_checks.csv