summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md19
-rw-r--r--game/src/lib.rs34
-rw-r--r--graphics/src/lib.rs14
3 files changed, 59 insertions, 8 deletions
diff --git a/README.md b/README.md
index 047b488..e62a2fe 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,25 @@
A rust Dungeon Crawler!
+## Keybinds
+
+Use the following input for playing the game~
+
+* `wasd` or `↑←↓→` for movement
+* `enter` for interaction
+* `e` to use an itemm
+* `q` to drop an item
+* `f` to attack
+* `1-5` to change selected inventory slot
+* `F11` to toggle fullscreen
+
+The following are for debug purposes
+
+* `F3` - toggles the debug ui
+* `F4` - places a chest with a bomb
+* `F5` - shows a placeholder message
+* `F6` - you die 💀
+
## Requirements
DungeonCrawl builds raylib into the binary, and thus needs the build tools needed for raylib.
diff --git a/game/src/lib.rs b/game/src/lib.rs
index 6e09a37..a5a07ba 100644
--- a/game/src/lib.rs
+++ b/game/src/lib.rs
@@ -103,19 +103,37 @@ impl Game {
}
}
+ fn handle_misc_input(&mut self) {
+ // 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.floor.get_mut(self.dungeon.player.entity.pos) =
+ Tile::Chest(Some(Item::Bomb));
+ }
+ if self.window.is_key_pressed(Key::F5) {
+ self.dungeon
+ .msg
+ .set_message("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ }
+ if self.window.is_key_pressed(Key::F6) {
+ self.dungeon.player.entity.health = 0;
+ }
+
+ // handle fulscreen
+ if self.window.is_key_pressed(Key::F11) {
+ self.window.toggle_fullscreen();
+ }
+ }
+
pub fn run(&mut self) {
play_sound!(self, &self.music.background);
// Main game loop
while self.window.is_open() {
- // 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.floor.get_mut(self.dungeon.player.entity.pos) =
- Tile::Chest(Some(Item::Bomb));
- }
+ // Handle misc input
+ self.handle_misc_input();
// Update game state
let inputs = self.get_player_input();
diff --git a/graphics/src/lib.rs b/graphics/src/lib.rs
index fa83b98..fdab836 100644
--- a/graphics/src/lib.rs
+++ b/graphics/src/lib.rs
@@ -43,6 +43,9 @@ pub enum Key {
// Debug keys
F3,
F4,
+ F5,
+ F6,
+ F11,
// Unknown/Unused key
Unknown(KeyboardKey),
}
@@ -79,6 +82,9 @@ impl From<KeyboardKey> for Key {
// Debug keys
K::KEY_F3 => Self::F3,
K::KEY_F4 => Self::F4,
+ K::KEY_F5 => Self::F5,
+ K::KEY_F6 => Self::F6,
+ K::KEY_F11 => Self::F11,
// Unknown/Unused key
_ => Self::Unknown(key),
}
@@ -117,6 +123,9 @@ impl From<Key> for KeyboardKey {
// Debug keys
Key::F3 => Self::KEY_F3,
Key::F4 => Self::KEY_F4,
+ Key::F5 => Self::KEY_F5,
+ Key::F6 => Self::KEY_F6,
+ Key::F11 => Self::KEY_F11,
// Unknown/Unused key
Key::Unknown(k) => k,
}
@@ -275,4 +284,9 @@ impl Window {
pub const fn audio(&mut self) -> &mut Audio {
&mut self.audio
}
+
+ /// Toggles fullscreen
+ pub fn toggle_fullscreen(&mut self) {
+ self.handle.toggle_fullscreen();
+ }
}