Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

This game is a rogue-like game that uses the libtcod library and is loosely based on the python rogue-like tutorial.

NotificationsYou must be signed in to change notification settings

kwoolter/roguelike

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kwoolter 🐒 ©️ 2020

Overview

This game is a rogue-like game that uses thelibtcod library and is loosely based on the python rogue-like tutorial.

Screenshots

new characterexploring
inventorycharacter

Controls

  • F1 help on controls available from current screen
  • Page Up andPage Down - change font size

Game Ready Screen

  • N create a new character
  • ENTER orSPACE to start the game
  • Esc quit the game

Create New Character Screen

  • N change player's name
  • C change player's class
  • R change player's race
  • ENTER orSPACE confirm race/class selection
  • Esc exit screen

Game Playing Screen

  • Arrow keys - move and attack enemy
  • 1 -4 - use spell in spell book slot
  • Ctrl attack current target with equipped weapon
  • G orSPACE get an item
  • Q orU use item currently equipped in Item slot
  • X examine item on floor
  • Z skip turn
  • C character screen
  • R inventory screen
  • J journal screen
  • K spell book
  • ENTER orV travel on stairs
  • Esc pause game

Game Paused Screen

  • Q quit the game
  • Esc continue playing game

Inventory Screen

  • Arrow keys orWASD change selected item
  • E equip an item
  • Q orU use an item
  • X examine an item
  • F drop an item
  • Esc orR exit screen

Spellbook Screen

  • UP/DOWN Arrow keys orWS change selected spell
  • LEFT/RIGHT Arrow keys orAD change selected spell level filter
  • M memorise/forget spell
  • L learn/unlearn spell
  • Esc orK exit screen

Character Screen

  • Arrow keys orWS change selected ability
  • L,E orSPACE level-up
  • U upgrade selected ability using Ability Points
  • Esc exit screen

Shop Screen

  • E orB switch to Buy tab
  • Q orV switch to Sell tab
  • Up and down arrow keys orW andS- change selected item
  • ENTER orSPACE buy/sell the selected item
  • Left and Right arrow keys orA andD - change item category in Buy tab
  • Esc exit screen

Game Over Screen

  • ENTER - continue to Game Ready Screen

Background

What is a rogue-like game?

What is thelibtcod library?

What is the Python rogue-like tutorial?

What is this game again?????

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

The Game Design

Package Structure

Overview:

  • roguelike
    • model - modules containing the classes for the game, floors, entities, etc.
    • view - modules containing the classes for all of the views
    • controller - main control loop
  • tutorial directory - how I started out following the python tutorial

model package

  • model.py - main module that containsModel,Floor,Room,Tunnel classes
  • entity_factory.py - containsEntity,EntityFactory,Player,Fighter,Inventory classes
  • combat.py - containsCombatEquipment,CombatEquipmentFactory,CombatClass,CombatClassFactory classes
  • spells.py - spells and spellbook related classes
  • events.py - all of the event names used in the game
  • themes.py - module for managing colour themes and random name generation
  • data directory - data files for the game
    • entities.csv - all of the game objects and their properties
    • combat_equipment.csv- more properties for entities that are armour or weapons
    • combat_classes.csv - the different types of fighter classes and their abilities
    • game_parameters.csv - the rules of how the game scales in difficulty
    • ability_checks.csv - which items can you perform an ability check on and what are the outcomes for success and failure
    • themes directory - data files for colour themes and random name generation
      • floor_palettes.csv - colour palettes for different themes
      • room_palettes.csv - room colours for different themes
      • rogue_history.cfg - config file for name generation usinglibtcod.namegen_generate() functionality
      • room_names.csv - not used anymore as switch to random name generation usinglibtcod library

view package

  • view.py - main module that containsMainFrame,FloorView and other UI View related classes
  • view_utils.py - utility classes for drawing stuff on a console
  • fonts directory - different font files that can be used withlibtcod
  • screenshots directory - screenshots of the game in action

controller package

  • controller.py - main game loop, keyboard event handling, orchestration of game states and UI states

Dependencies

  • 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 calculations
  • pandas - used for loading incsv files that hold the game data e.g. entities, combat items, etc.
  • pygame - only used for theRect class

How Does The Game's Difficulty Scale?

Basic Concept

TheEntity objects that appear in the game have a count and probability metric defined either for the currentFloor or for each individualRoom on theFloor.
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 metricy you can specify how it is calculated using this formula:

y = a*x + b + (x//d) * ad

Wherex 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 representsthe slope of the line andb is the y intercept. However, you may want an increasing number of rats at lower dungeonlevels but no rats beyond level 10. To support this you can add (or subtract)x DIVd 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 constrainy 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 calculatey:

        # 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 isy = ax + b,the blue line is(x div d) * ad and the grey line isy 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 interestingcurves for count and probability for eachEntity in the game.

game_parameters.csv file

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 - slope
  • b - y intercept
  • d - x DIV value
  • ad - x DIV value slope
  • min - 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 shareCount orProbability curves across multiple types ofEntity

entities.csv file

EachEntity 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 messages
  • Char - the character used to represent theEntity on the gameFloorView
  • Category - group entities together by category
  • FG - foreground colour
  • BG - background colour
  • Zorder - order of display in descending order i.e. 0 is draw last
  • IsTransparent - 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?

Adding new Entities

The process for adding new types ofEntity to the game is as follows:-

  1. Add a new row toentities.csv
  2. Add 2 new rows togame_parameters.csv; one for generatingCount and one forProbability metrics
  3. If the newEntityis a piece ofCombatEquipment then add a new row tocombat_equipment.csv
  4. If you can ability check theEntity then add a new row toability_checks.csv

Useful Links

libtcod Documentation

Tutorial on writing a game usinglibtcod

Fonts that you can load intolibtcod

libtcod pre-defined colours

About

This game is a rogue-like game that uses the libtcod library and is loosely based on the python rogue-like tutorial.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp