Skip to content

Gme-muriuki/Blackspire

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

22 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Blackspire

A classic roguelike blackspire game built with Rust, featuring procedurally generated dungeons, turn-based combat, and an Entity Component System (ECS) architecture. Navigate through dangerous levels, battle monsters, collect items, and retrieve the legendary Amulet of Yala to save your hometown!

๐ŸŽฎ Features

  • Procedurally Generated Dungeons: Three different map generation algorithms (Rooms, Cellular Automata, Drunkard's Walk) create unique dungeons every playthrough
  • Turn-Based Combat: Strategic turn-based gameplay where every move matters
  • Field of View: Realistic line-of-sight mechanics - you can only see what your character can see
  • Multiple Enemy Types: Face off against Goblins, Orcs, Ogres, and Ettins, each with different stats and behaviors
  • Item System: Collect and use healing potions, weapons, and magical items
  • Multiple Levels: Progress through multiple dungeon levels, each more challenging than the last
  • Themes: Different visual themes (Dungeon, forest, ice, ...) for varied aesthetics
  • HUD: Comprehensive heads-up display showing health, inventory, and game information
  • Tooltips: Hover over entities to see their names and details

๐Ÿ› ๏ธ Technology Stack

  • Language: Rust (Edition 2021+)
  • ECS Framework: Legion - High-performance Entity Component System
  • Game Engine: bracket-lib - Terminal-based game library
  • Serialization: RON - Rusty Object Notation for template files
  • Serialization Framework: Serde - Framework for serializing and deserializing Rust data structures

๐Ÿ“‹ Prerequisites

Before you begin, ensure you have the following installed:

  • Rust: Version 1.70.0 or later
    • Install from rustup.rs
    • Verify installation: rustc --version
  • Cargo: Comes bundled with Rust
    • Verify installation: cargo --version

Platform-Specific Requirements

Windows

  • Visual Studio Build Tools or Visual Studio with C++ development tools
  • Windows SDK

Linux

  • build-essential package (includes GCC, make, etc.)
    sudo apt-get update
    sudo apt-get install build-essential

macOS

  • Xcode Command Line Tools
    xcode-select --install

๐Ÿš€ Installation

  1. Clone the repository

    git clone https://github.com/pragmatic-rustacean/Blackspire.git
    cd blackspire/blackspire
  2. Verify the project structure Ensure you have the following structure:

    blackspire/
    โ”œโ”€โ”€ Cargo.toml
    โ”œโ”€โ”€ src/
    โ”‚   โ”œโ”€โ”€ main.rs
    โ”‚   โ””โ”€โ”€ ...
    โ””โ”€โ”€ resources/
        โ”œโ”€โ”€ dungeonfont.png
        โ”œโ”€โ”€ terminal8x8.png
        โ””โ”€โ”€ template.ron
    

๐Ÿ”จ Building and Compiling

Debug Build

Build the project in debug mode (faster compilation, slower runtime):

cargo build

The executable will be located at: target/debug/blackspire.exe (Windows) or target/debug/blackspire (Linux/macOS)

Release Build

Build an optimized release version (slower compilation, faster runtime):

cargo build --release

The optimized executable will be located at: target/release/blackspire.exe (Windows) or target/release/blackspire (Linux/macOS)

Note: The release build uses Link-Time Optimization (LTO) for maximum performance.

Check for Compilation Errors

Check if the code compiles without building:

cargo check

โ–ถ๏ธ Running the Game

Quick Start

Run the game directly with Cargo (debug mode):

cargo run

Run the optimized release version:

cargo run --release

Running the Executable Directly

After building, you can run the executable directly:

Windows:

.\target\release\blackspire.exe

Linux/macOS:

./target/release/blackspire

Important: Make sure you run the executable from the blackspire directory, as the game expects the resources/ folder to be in the current working directory. You can also copy the executable to a different folder but ensure you also copy the resources folder into the folder that contains your executable.

๐ŸŽฏ How to Play

Objective

Your goal is to navigate through multiple dungeon levels, defeat monsters, collect items, and ultimately retrieve the Amulet of Yala on the final level to save your hometown.

Controls

Key Action
โ†‘ โ†“ โ† โ†’ Move player (Arrow Keys)
G Pick up item at current location
0-9 Use item from inventory (0-9 correspond to inventory slots)

Gameplay Mechanics

  • Turn-Based: The game uses a turn-based system. After you move, enemies take their turn
  • Combat: Move into an enemy to attack them. Combat is automatic
  • Health: Your health is displayed in the HUD. If it reaches 0, it's game over
  • Field of View: You can only see tiles within your field of view radius
  • Level Progression: Find the exit staircase (>) to advance to the next level
  • Victory: Collect the Amulet of Yala (|) on the final level to win

Items

  • Healing Potion (!): Restores health when used
  • Dungeon Map ({): Reveals the entire map
  • Rusty Sword (/): Weapon that increases damage
  • Shiny Sword (S): Better weapon with higher damage
  • Huge Sword (/): Powerful weapon for later levels

Enemies

  • Goblin (g): Weak enemy, 1 HP, appears on all levels
  • Orc (o): Moderate enemy, 2 HP, appears on all levels
  • Ogre (O): Strong enemy, 5 HP, appears on levels 1-2
  • Ettin (E): Very strong enemy, 10 HP, appears on level 2

๐Ÿ“ Project Structure

blackspire/
โ”œโ”€โ”€ Cargo.toml              # Project metadata and dependencies
โ”œโ”€โ”€ Cargo.lock              # Locked dependency versions
โ”œโ”€โ”€ README.md               # This file
โ”œโ”€โ”€ resources/              # Game assets
โ”‚   โ”œโ”€โ”€ dungeonfont.png    # Main game font
โ”‚   โ”œโ”€โ”€ terminal8x8.png    # Terminal font
โ”‚   โ””โ”€โ”€ template.ron       # Entity templates (monsters, items)
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.rs            # Entry point and game loop
โ”‚   โ”œโ”€โ”€ camera.rs          # Camera system for viewport
โ”‚   โ”œโ”€โ”€ components.rs      # ECS component definitions
โ”‚   โ”œโ”€โ”€ map.rs             # Map and tile definitions
โ”‚   โ”œโ”€โ”€ player.rs          # Player-related logic
โ”‚   โ”œโ”€โ”€ turn_state.rs      # Game state machine
โ”‚   โ”œโ”€โ”€ map_builder/       # Procedural map generation
โ”‚   โ”‚   โ”œโ”€โ”€ mod.rs
โ”‚   โ”‚   โ”œโ”€โ”€ automata.rs    # Cellular automata algorithm
โ”‚   โ”‚   โ”œโ”€โ”€ drunkard.rs    # Drunkard's walk algorithm
โ”‚   โ”‚   โ”œโ”€โ”€ rooms.rs       # Room-based algorithm
โ”‚   โ”‚   โ”œโ”€โ”€ prefab.rs      # Prefab room placement
โ”‚   โ”‚   โ””โ”€โ”€ themes.rs      # Visual themes
โ”‚   โ”œโ”€โ”€ spawner/           # Entity spawning logic
โ”‚   โ”‚   โ”œโ”€โ”€ mod.rs
โ”‚   โ”‚   โ””โ”€โ”€ template.rs    # Template loading and spawning
โ”‚   โ””โ”€โ”€ systems/           # ECS systems
โ”‚       โ”œโ”€โ”€ mod.rs
โ”‚       โ”œโ”€โ”€ chasing.rs     # Enemy AI - chasing player
โ”‚       โ”œโ”€โ”€ combat.rs      # Combat resolution
โ”‚       โ”œโ”€โ”€ end_turn.rs    # Turn state transitions
โ”‚       โ”œโ”€โ”€ entity_render.rs # Entity rendering
โ”‚       โ”œโ”€โ”€ fov.rs         # Field of view calculations
โ”‚       โ”œโ”€โ”€ hud.rs         # Heads-up display
โ”‚       โ”œโ”€โ”€ map_render.rs  # Map rendering
โ”‚       โ”œโ”€โ”€ movement.rs    # Movement handling
โ”‚       โ”œโ”€โ”€ player_input.rs # Player input handling
โ”‚       โ”œโ”€โ”€ random_move.rs # Enemy AI - random movement
โ”‚       โ”œโ”€โ”€ tooltip.rs     # Tooltip system
โ”‚       โ””โ”€โ”€ use_item.rs    # Item usage system
โ””โ”€โ”€ target/                # Build output (gitignored)

๐Ÿ› Troubleshooting

Common Issues

Issue: Game crashes with "Couldn't find specified file" error

  • Solution: Make sure you're running the game from the dungeon-dragons directory where the resources/ folder is located

Issue: Build fails with linker errors

  • Solution: Ensure you have the required build tools installed for your platform (see Prerequisites)

Issue: Game runs slowly

  • Solution: Use the release build (cargo run --release) instead of debug build

Issue: Fonts not displaying correctly

  • Solution: Verify that resources/dungeonfont.png and resources/terminal8x8.png exist in the correct location

๐Ÿค Contributing

Contributions are welcome! This project follows open-source best practices and we appreciate your help in making it better.

How to Contribute

  1. Fork the repository

    • Click the "Fork" button on GitHub
  2. Create a feature branch

    git checkout -b feature/your-feature-name

    Or for bug fixes:

    git checkout -b fix/your-bug-fix
  3. Make your changes

    • Write clean, well-commented code
    • Follow Rust conventions and style guidelines
    • Add comments for complex logic
    • Update documentation as needed
  4. Test your changes

    cargo build --release
    cargo run --release

    Ensure the game compiles and runs correctly

  5. Commit your changes

    git add .
    git commit -m "Description of your changes"

    Write clear, descriptive commit messages

  6. Push to your fork

    git push origin feature/your-feature-name
  7. Create a Pull Request

    • Go to the original repository on GitHub
    • Click "New Pull Request"
    • Select your fork and branch
    • Fill out the PR template with:
      • Description of changes
      • What was changed and why
      • Any breaking changes
      • Screenshots (if UI changes)

Contribution Guidelines

  • Code Style: Follow Rust's official style guide. Use cargo fmt to format your code
  • Documentation: Add doc comments for public functions and types
  • Testing: Add tests for new features when possible
  • Breaking Changes: Clearly document any breaking changes in your PR
  • Issues: Before starting work on a large feature, consider opening an issue to discuss it first

Areas for Contribution

  • ๐Ÿ› Bug fixes
  • โœจ New features (new enemies, items, map generation algorithms)
  • ๐Ÿ“š Documentation improvements
  • ๐ŸŽจ UI/UX enhancements
  • โšก Performance optimizations
  • ๐Ÿงช Additional tests
  • ๐ŸŒ Localization support

๐Ÿ“ Code of Conduct

This project adheres to a code of conduct that all contributors are expected to follow:

  • Be respectful and inclusive
  • Welcome newcomers and help them learn
  • Focus on constructive feedback
  • Respect different viewpoints and experiences

๐Ÿ“„ License

This project is currently unlicensed. If you'd like to use this code, please contact the author or consider adding a license file.

๐Ÿ™ Acknowledgments

  • Built with bracket-lib by The Amethyst Foundation
  • Uses Legion ECS for entity management
  • Inspired by classic roguelike games like Rogue, NetHack, and Angband

๐Ÿ“ง Contact

Author: James Muriuki Maina
Email: geniusinrust@gmail.com

๐Ÿ”ฎ Future Plans

Potential features for future versions:

  • Save/Load game functionality
  • More enemy types and behaviors
  • Additional items and equipment
  • Character classes with unique abilities
  • More map generation algorithms
  • Sound effects and music
  • Configurable keybindings
  • Difficulty levels
  • High score system
  • Multiplayer support

๐Ÿ“Š Project Status

Current Version: 0.1.0 (MVP)

This project is currently in MVP (Minimum Viable Product) status. The core gameplay loop is complete and functional, but there's plenty of room for expansion and improvement.


Enjoy your dungeon crawling adventure! ๐Ÿ—ก๏ธ๐Ÿ›ก๏ธโš”๏ธ

About

Blackspire is a turn-based roguelike game written in Rust, with procedurally generated dungeons, ECS architecture (Legion), and terminal rendering via bracket-lib, showcasing my experience with game loops, AI, and systems design

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages