summaryrefslogtreecommitdiff
path: root/graphics/src/lib.rs
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-10-07 11:01:19 -0400
committerFreya Murphy <freya@freyacat.org>2025-10-08 19:37:15 -0400
commitb11f074ceba10af62b35b414ecaa51a8f13c6550 (patch)
treed12979f7eeb384f94b145ea763a97dcde353745b /graphics/src/lib.rs
parentInitial commit (diff)
downloadDungeonCrawl-b11f074ceba10af62b35b414ecaa51a8f13c6550.tar.gz
DungeonCrawl-b11f074ceba10af62b35b414ecaa51a8f13c6550.tar.bz2
DungeonCrawl-b11f074ceba10af62b35b414ecaa51a8f13c6550.zip
initial baseline
Diffstat (limited to 'graphics/src/lib.rs')
-rw-r--r--graphics/src/lib.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/graphics/src/lib.rs b/graphics/src/lib.rs
new file mode 100644
index 0000000..c0b0019
--- /dev/null
+++ b/graphics/src/lib.rs
@@ -0,0 +1,31 @@
+use dungeon::Dungeon;
+use raylib::prelude::*;
+
+pub struct Window {
+ handle: RaylibHandle,
+ thread: RaylibThread,
+}
+impl Window {
+ /// Instantiates a new window provided with the default
+ /// window `width`, `height`, and `title`.
+ pub fn new(width: i32, height: i32, title: &str) -> Self {
+ let (handle, thread) = raylib::init()
+ .size(width, height)
+ .title(title)
+ .resizable()
+ .log_level(TraceLogLevel::LOG_WARNING)
+ .build();
+ Self { handle, thread }
+ }
+
+ /// Returns if the window should be closed.
+ /// This usually means the 'x' button has been pressed.
+ pub fn is_open(&self) -> bool {
+ !self.handle.window_should_close()
+ }
+
+ /// Draws a frame provided with the game state `Dungeon`
+ pub fn draw(&mut self, _dungeon: &Dungeon) {
+ let _draw = self.handle.begin_drawing(&self.thread);
+ }
+}