diff options
| author | Freya Murphy <freya@freyacat.org> | 2025-11-14 23:30:05 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2025-11-14 23:30:05 -0500 |
| commit | 65f5143d3e01e111afb960451e0741ddb37be240 (patch) | |
| tree | d59bc1e885aa31743fd87ebadab8e1728e2cd683 /game | |
| parent | graphics: use 32bit color for atlas (diff) | |
| download | DungeonCrawl-65f5143d3e01e111afb960451e0741ddb37be240.tar.gz DungeonCrawl-65f5143d3e01e111afb960451e0741ddb37be240.tar.bz2 DungeonCrawl-65f5143d3e01e111afb960451e0741ddb37be240.zip | |
graphics: add text message rendering (and sans ig)
Diffstat (limited to 'game')
| -rw-r--r-- | game/src/main.rs | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/game/src/main.rs b/game/src/main.rs index b79331b..82b1ad2 100644 --- a/game/src/main.rs +++ b/game/src/main.rs @@ -1,5 +1,5 @@ use argh::FromArgs; -use dungeon::{Dungeon, player_input::PlayerInput, pos::Direction}; +use dungeon::{Dungeon, UpdateResult, player_input::PlayerInput, pos::Direction}; use graphics::{Key, Window, WindowBuilder}; struct Game { @@ -15,6 +15,7 @@ impl Game { Some(s) => Dungeon::new(s), None => Dungeon::random(), }; + Self { window, dungeon, @@ -60,18 +61,38 @@ impl Game { fn run(&mut self) { // Main game loop while self.window.is_open() { - // Handle keyboard input + // Handle debug keys if self.window.is_key_pressed(Key::F3) { self.window.toggle_debug(); } + if self.window.is_key_pressed(Key::F4) { + self.dungeon + .msg + .set_message("Lorem ipsum dolor sit amet consectetur adipiscing elit"); + } let inputs = PlayerInput { direction: self.player_dir(), + interact: self.window.is_key_pressed(Key::Return), }; // Update game state - self.dungeon + let result = self + .dungeon .update(inputs, self.window.delta_time().as_secs_f32()); + match result { + UpdateResult::EntityMovement => {} + UpdateResult::MessageUpdated(changed) => { + if changed { + self.window.audio().speak.play(); + } + } + } + + // Update on screen message + if self.dungeon.msg.update(inputs) { + self.window.audio().speak.play(); + } // Draw a single frame self.window.draw_frame(&self.dungeon); |