diff options
| author | alf9310 <alf9310@rit.edu> | 2025-10-17 15:38:25 -0400 |
|---|---|---|
| committer | alf9310 <alf9310@rit.edu> | 2025-10-17 15:38:25 -0400 |
| commit | c7e3a6468dca4c392221481144b97eaa344df4f3 (patch) | |
| tree | e3b489a5e682667dd9bb8c2b87b18076fefcb8cf /docs | |
| parent | Added render documentation (diff) | |
| download | DungeonCrawl-c7e3a6468dca4c392221481144b97eaa344df4f3.tar.gz DungeonCrawl-c7e3a6468dca4c392221481144b97eaa344df4f3.tar.bz2 DungeonCrawl-c7e3a6468dca4c392221481144b97eaa344df4f3.zip | |
Finished Components Documentation
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/Proposal.md | 86 |
1 files changed, 75 insertions, 11 deletions
diff --git a/docs/Proposal.md b/docs/Proposal.md index 76e8bd6..db1bbae 100644 --- a/docs/Proposal.md +++ b/docs/Proposal.md @@ -31,36 +31,100 @@ into the ever-changing depths. - After winning, the player collects loot and continues exploring until finding the staircase to the next floor. - Difficulty increases as the player descends deeper. - -One or more typical “use cases”. These might include “storyboards” explaining - how a user would interact with the program or some interesting “input/output” - examples. - ## Components ### **Game Binary Crate** - **[main](game\src\main.rs)** - Initializes the game state and handles the Model-View-Controller loop. +- **input.rs** - Handles keyboard/mouse/controller events and translates them into gameplay actions. + - ```enum InputEvent { Move(Direction), Attack, UseItem(usize), NextFloor }``` + - ```pub fn poll_input() -> Option<InputEvent>``` — Returns the next player input event, if available. ### **Dungeon Library Crate** Core functionality for interacting with a `Dungeon` data structure and its components. - - `Dungeon` - The game state of the dungeon crawler. + - `Dungeon` - The game state of the dungeon crawler. +```rust + pub struct Dungeon { + pub floor: Floor, + pub player: Entity, + pub enemies: Vec<Entity>, + pub items: Vec<Item>, + pub depth: u32, + pub rng: StdRng, + } +``` + - ```pub fn new_seeded(seed: u64) -> Self``` Create a new dungeon with it's components determanistically. + - ```pub fn update(&mut self, action: Action)``` Applies a player or AI action to the game state. + - ```pub fn next_floor(&mut self)``` Generates a new Floor when the player descends stairs. - **[Map Module](dungeon\src\map.rs)** - Structures for the dungeon game map including the current `Floor`, map `Tile`, and `Entity`. - `Floor` - Current playing grid of the dungeon. It contains the tiles of the grid, and the starting position of the player. + - ```pub fn generate_seeded(_seed: u64) -> Self``` Genreates a dungeon `Floor` using wave function collapse provided with a seed. The provided seed is used for randomness in the wave function collapse algorithm. - `Tile` - Enum that represents what is (or is not) at any given spot in the dungeon grid. +```rust +pub enum Tile { + Floor, + Air, + StairDown, +} +``` - `Entity` - The main player, or any other ai autonomous character that can move freely across the dungeon. + - ```pub const fn new(pos: Pos, dir: Direction, kind: EntityKind) -> Self``` Creates a new `Entity` at a given `Pos`, `Direction`, and `EntityKind`. + - ``` pub fn take_turn(&mut self, dungeon: &mut Dungeon)``` — Simple AI behavior for enemies. + - `Item` - An item that can be picked up by the player entity +- **Player Module** - Data specific to the player character, including inventory +```rust +pub struct Player { + pub entity: Entity, + pub hp: i32, + pub atk: i32, + pub def: i32, + pub xp: u32, + pub inventory: Vec<Item>, +} +``` + - ```pub fn attack(&self, target: &mut Entity)``` — Executes a basic attack. + - ```pub fn use_item(&mut self, index: usize)``` — Uses an item from the inventory. + - ```pub fn gain_xp(&mut self, amount: u32)``` — Increases player XP and handles leveling up. +- **Item Module** - Manages collectible and usable items. +```rust +pub struct Item { + pub name: String, + pub kind: ItemKind, + pub pos: Pos, +} +``` + - `Item Kind` - Enum describing item type +```rust +pub enum ItemKind { + Potion { heal: i32 }, + Weapon { atk_bonus: i32 }, + Armor { def_bonus: i32 }, +} +``` +- **Combat Module** - Handles combat resolution and damage calculations. +```rust +pub struct CombatResult { + pub damage_dealt: i32, + pub target_died: bool, +} +``` + - ```pub fn calculate_damage(atk: i32, def: i32) -> i32``` — Core formula for combat outcomes. - **[Position Module](dungeon\src\pos.rs)** - Structures for representation an entity or objects position and facing direction inside the dungeon grid. - `Direction` - Enum that representa the direction an entity or any position object is facing inside the dungeon map. Since the dungeon lives on a grid, there are only four possible directions. - `Pos` - 2D position inside the dungeon grid. + - ```pub const fn step(self, dir: Direction) -> Option<Self>``` Steps `Pos` one space in the `Direction` `dir`. Returns `None` if the position goes out of the map. ### **Graphics Library Crate** Core functionality for rendering using the `raylib` library. Independent from game logic. + - `Window` - The game window containing rayLib Handle and Thread + - `pub fn renderer(&mut self) -> Renderer<'_>` - Returns the renderer for the game. - **[Render Module](graphics\src\render.rs)** - The `render` module contains the structures for displaying the game, with each frame represented by a `Renderer` and frame specific information in `FrameInfo`. - - - - - + - `FrameInfo` - Contains information about the current frame being rendered. + - `Renderer` - Renderer for a single frame of the game. It is created per frame. + - `pub fn draw_frame(&mut self, dungeon: &Dungeon)` Draws an entire frame + - `pub fn draw_entity(&mut self, entity: &Entity)` Draws a player or enemy sprite. + - `pub fn draw_tile(&mut self, tile: &Tile, pos: Pos)` Draws a tile at a position. + - `pub fn draw_ui(&mut self, player: &Player)` Renders player HP, inventory, and floor number. -- A sketch of intended components (key functions, key data structures, separate modules). ## Testing - Thoughts on testing. These might include critical functions or data structures |