summaryrefslogtreecommitdiff
path: root/graphics/src/lib.rs
blob: 4187e6b1d5677abbca71d5d215f8f7c84e59d662 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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 (mut handle, thread) = raylib::init()
			.size(width, height)
			.title(title)
			.resizable()
			.log_level(TraceLogLevel::LOG_WARNING)
			.build();
		// Set the target FPS (TODO: modify based on target system)
		handle.set_target_fps(60);
		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 mut draw = self.handle.begin_drawing(&self.thread);

		// Clear the background to black
		draw.clear_background(Color::BLACK);

		draw.draw_text("test", 10, 10, 20, Color::GREEN);
	}

	/// Draw game over screen
	pub fn game_over(&mut self) {
		!unimplemented!()
	}

	/// Draw player sprites
	pub fn draw_player(&mut self, _dungeon: &Dungeon) {
		!unimplemented!()
	}

	/// Draw dungeon tiles
	pub fn draw_tiles(&mut self, _dungeon: &Dungeon) {
		!unimplemented!()
	}
}