Class Diagram
The following diagram illustrates the core class hierarchy of Pixel Dungeon, including game structure, actors, items, and level generation systems.
Note: The diagram shows the primary relationships between classes. Some simplifications were made for clarity. The PD-classes repository provides base classes while the pixel-dungeon repository contains the game implementation.
Sequence Diagram
The following sequence diagram illustrates the main game flow, including initialization, level generation, turn processing, and combat.
Note: This sequence diagram illustrates the main game flow, focusing on initialization, level generation, and turn-based gameplay. The actual implementation may have additional complexity. The turn system in Pixel Dungeon is based on time units spent by each Actor.
Key Game Components
Actor System
The Actor system is the foundation of all entities that can take actions in the game. Actors are scheduled to act based on time spent. The main classes in this hierarchy are:
- Actor: Base class with timing system
- Char: Living entities with health and position
- Mob: Enemies with AI states
- Hero: Player-controlled character
- Buff: Temporary effects on characters
Item System
The Item system handles all collectible objects in the game. Items can be used, equipped, or thrown. Major categories include:
- Weapon: Melee weapons, missile weapons
- Armor: Protective equipment with glyphs
- Wand: Magical devices with charges
- Potion: Consumable effects
- Scroll: Single-use magical items
- Ring: Passive effect items
Level Generation
Levels are procedurally generated using a room-based approach:
- Level: Base class with map data
- RegularLevel: Standard level with rooms
- Room: Rectangular areas with various types
- Painter: Renders room contents to the map
The generation process: initialize rooms → place doors → add items → add monsters → place traps.
Rendering System
The visual representation is handled by scene classes:
- Scene: Base visual container
- PixelScene: Pixel-art specific rendering
- GameScene: Main gameplay screen
- DungeonTilemap: Renders level tiles
- CharSprite: Visual representation of characters