How vozderjus/qualia works
1. Project shape
- Qualia is a single-player 2D roguelike built in Python with pygame-ce.
- The repo is organized around a classic game architecture: entrypoint/game loop, state-based screens, entity system, procedural world generation, and supporting UI/audio assets.
2. Entry point and runtime loop
- qualia/game.py is the main executable entrypoint.
- qualia/game_settings.py, qualia/run_state.py, and qualia/constants.py suggest a central runtime configuration/state layer used by the loop and the screens.
- The game updates over delta time rather than fixed FPS logic, which affects movement, cooldowns, animations, and combat timing.
3. Screen/state architecture
- qualia/states/ contains the game’s major modes: title screen, world gameplay, pause menu, settings, shop, game over, victory, debug HUD, and player UI.
- qualia/states/state.py is the base state abstraction; other states likely implement a common update/render/input interface.
- This means the application is structured as a state machine: only one high-level state is active at a time, with transitions driven by input and game events.
4. World gameplay boundary
- qualia/states/game_world.py appears to be the main in-game state that ties together level generation, combat, entities, and world interactions.
- The qualia/world/ package is the boundary for level construction and level-level systems, separating “what the floor is” from “what the entities do.”
5. Procedural generation pipeline
- Two generation strategies are present:
- qualia/world/bsp_generator.py for room-based dungeon floors.
- qualia/world/maze_generator.py for the labyrinth floor.
- qualia/world/floor_builder.py, floor_definitions.py, level.py, and room_layout_cache.py likely assemble generated layouts into playable floors and persist reusable room layouts.
- The README’s validation step corresponds to tests/test_bsp_generator.py, tests/test_maze_generator.py, and tests/test_level.py, implying generation is treated as a core subsystem with correctness checks.
6. World simulation systems
- qualia/world/combat_system.py, encounter_manager.py, room_lock_system.py, and world_interaction_system.py indicate the floor is not just geometry; it also has systems that:
- spawn or manage room encounters,
- lock/unlock progression,
- resolve interactions with exits, doors, pickups, and shop flow,
- coordinate combat triggers and room progression.
- This is the main “gameplay orchestration” layer beneath the screen/state layer.
7. Entity model
- qualia/entities/ contains the moving/combat actors and interactive objects.
- Player/combat entities include player.py, bullet.py, multiple enemy classes, boss_enemy.py, heat_pickup.py, level_exit.py, shop_keeper.py, room_door.py, and floating_damage_text.py.
- Shared behavior modules like movement_behaviors.py, attack_behaviors.py, boss_behaviors.py, and attack_command.py suggest composition over inheritance for AI and attack patterns.
8. Combat and AI flow
- The combat loop is centered on the player firing bullets and enemies executing behavior-driven attacks.
- Enemy variants such as blue_eye_enemy.py, orange_eye_enemy.py, heart_enemy.py, prism_enemy.py, teeth_enemy.py, and basic_enemy.py imply multiple AI archetypes with distinct movement/attack logic.
- The boss uses phase-based behavior changes through boss_behaviors.py, matching the README’s multi-phase boss description.
- Projectiles and enemy attacks are likely resolved against world geometry and actors using collision checks inside the entity/world systems.
9. Camera, rendering, and presentation
- qualia/entities/camera.py and qualia/world/level_renderer.py indicate a dedicated camera/rendering path for drawing the current floor relative to the player.
- qualia/entities/floating_damage_text.py and qualia/states/player_ui.py suggest separate layers for combat feedback and HUD.
- qualia/ui_helpers.py and qualia/uis.py are likely shared UI building blocks used by menus, the shop, and settings.
10. Menus and meta-progression
- qualia/states/title.py, pause_menu.py, settings_menu.py, shop_menu.py, game_over.py, and game_victory.py define the non-gameplay screens.
- qualia/settings_content.py and qualia/shop_content.py appear to hold data/configuration for settings options and purchasable upgrades.
- The shop is a distinct gameplay boundary: it consumes the in-game currency heat/жар via heat_pickup.py and likely upgrades player capabilities between encounters.
11. Audio and art asset pipeline
- audio/ contains background music per floor plus weapon, hit, pickup, and UI sounds.
- images/ contains .aseprite source art for enemies, the boss, and wall tiles.
- qualia/audio_manager.py is the runtime bridge between the game and audio assets, while the asset folders are the content boundary for presentation and feedback.
12. Testing and reliability
- Tests cover generation and core runtime pieces: bsp_generator, maze_generator, level, encounter_manager, game_settings, and run_state.
- That distribution shows the repo prioritizes deterministic behavior in its procedural generation and core state/configuration logic.
- For architecture diagrams, the most important distinction is between deterministic world-building code and real-time simulation/UI code.
13. High-level data flow
- Input enters through pygame and is consumed by the active state.
- The active state delegates to world systems and entities.
- World systems update the level, combat, collisions, and interactions.
- Entities produce visible effects and UI feedback.
- State transitions happen on events such as death, victory, pause, shop entry, or floor completion.
14. Key boundaries to show in a diagram
- Entry/runtime: game.py and run-state/config.
- State machine: title/gameplay/shop/settings/pause/end states.
- World generation: BSP/maze builders and validation.
- Simulation: combat, encounters, doors, exits, interactions.
- Entities: player, enemies, bullets, boss, pickups.
- Presentation: rendering, UI, camera, debug HUD.
- Content/assets: audio and art files feeding the runtime.
Main entry points: game_world.py World state · floor_builder.py Floor build · game.py Game · level_renderer.py Renderer
Components 33
Runtime
Entry point and shared game configuration
States
State machine screens and overlays
- State base · Common screen/state contract
qualia/states/state.py - Title · Main menu and start flow
qualia/states/title.py - World state · Primary in-game simulation state
qualia/states/game_world.py - Pause · Pause overlay and resume flow
qualia/states/pause_menu.py - Shop · Between-floor upgrade screen
qualia/states/shop_menu.py - End screens · Game over and victory flows
World
Floor generation and simulation systems
- BSP gen · Room-based dungeon generation
qualia/world/bsp_generator.py - Maze gen · Labyrinth floor generation
qualia/world/maze_generator.py - Floor build · Assembles generated floors
qualia/world/floor_builder.py - Level · Floor data and gameplay geometry
qualia/world/level.py - Encounters · Room encounter spawning and flow
qualia/world/encounter_manager.py - Combat · Combat resolution and timing
qualia/world/combat_system.py - Room locks · Locks and unlocks room progression
qualia/world/room_lock_system.py - Interactions · Doors, exits, pickups, and flow
qualia/world/world_interaction_system.py
Entities
Actors, projectiles, and interactables
- Player · Controllable combat character
qualia/entities/player.py - Bullet · Player projectile entity
qualia/entities/bullet.py - Enemies · Enemy archetypes and variants
- Boss · Multi-phase boss enemy
qualia/entities/boss_enemy.py - Pickups & exits · Heat, exits, doors, shopkeeper
- Behaviors · Movement and attack behavior composition
qualia/entities/attack_behaviors.py - Boss phases · Phase-driven boss behavior changes
qualia/entities/boss_behaviors.py
Presentation
Camera, rendering, and UI
- Renderer · Draws the current floor
qualia/world/level_renderer.py - Camera · World-to-screen framing
qualia/entities/camera.py - HUD · Player combat and status UI
qualia/states/player_ui.py - Debug HUD · Debug diagnostics overlay
qualia/states/debug_hud.py - Audio · Runtime sound and music control
qualia/audio_manager.py - UI helpers · Shared UI building blocks
qualia/ui_helpers.py - Widgets · Reusable UI primitives
qualia/uis.py
Content
Audio and art assets
- Audio assets · Music and sound effects
audio - Art assets · Sprite and tile source art
images
Connections 32
- Game → Run state: uses · Initializes and advances runtime state
- Game → Settings: loads · Reads configuration for startup and play
- Game → Title: starts · Enters the title/menu flow
- State base → Title: base for · Common interface for screens
- State base → World state: base for · Common interface for screens
- World state → Level: owns · Hosts the active floor model
- World state → Encounters: drives · Coordinates room progression
- World state → Combat: drives · Updates combat timing and resolution
- World state → Room locks: drives · Controls room access and unlocking
- World state → Interactions: drives · Handles exits, doors, and pickups
- Floor build → BSP gen: builds via · Creates room-based floors
- Floor build → Maze gen: builds via · Creates maze floors
- Floor build → Level: produces · Outputs playable level data
- World state → Floor build: requests · Constructs the next floor
- Renderer → Camera: uses · Frames world drawing
- World state → Renderer: renders with · Draws the active floor
- World state → HUD: overlays · Shows health, heat, and combat status
- World state → Debug HUD: overlays · Optionally shows debug information
- Player → Bullet: fires · Creates projectiles during combat
- Behaviors → Enemies: drives · Shared movement and attack patterns
- Boss phases → Boss: drives · Phase-based boss logic
- Pickups & exits → Interactions: triggered by · Interactive world objects feed progression
- Player → Behaviors: clashes with · Enemies respond to player presence
- World state → Player: spawns · Places the controllable actor in the floor
- World state → Enemies: spawns · Populates encounters with enemies
- World state → Boss: spawns · Creates boss encounters on boss floors
- World state → Pickups & exits: spawns · Adds exits, doors, heat, and shop flow
- UI helpers → Widgets: builds · Shared UI construction pieces
- Title → Audio: plays · Menu music and feedback
- World state → Audio: plays · Combat and floor audio cues
- Audio → Audio assets: loads · Uses sound and music files
- Renderer → Art assets: draws from · Uses sprite and tile art