summaryrefslogtreecommitdiff
path: root/graphics/src/render.rs
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/src/render.rs')
-rw-r--r--graphics/src/render.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/graphics/src/render.rs b/graphics/src/render.rs
index add19ab..68a7b68 100644
--- a/graphics/src/render.rs
+++ b/graphics/src/render.rs
@@ -1,10 +1,15 @@
+//! The `render` module contains the structures for displaying
+//! the game, with each frame represented by a `Renderer` and
+//! frame specific information in `FrameInfo`.
+
use dungeon::{Dungeon, Entity};
use raylib::{
color::Color,
prelude::{RaylibDraw, RaylibDrawHandle, RaylibHandle},
};
-/// Information used each frame
+/// The `FrameInfo` struct contains information about
+/// the current frame being rendered.
pub struct FrameInfo {
/// Time in seconds since last frame drawn
pub delta: f32,
@@ -12,6 +17,8 @@ pub struct FrameInfo {
pub fps: u32,
}
impl FrameInfo {
+ /// Creates a new `FrameInfo` from the provided
+ /// `RaylibHandle`.
pub fn new(handle: &RaylibHandle) -> Self {
Self {
delta: handle.get_frame_time(),
@@ -58,6 +65,16 @@ impl<'a> Renderer<'a> {
}
/// Draws an entire frame
+ ///
+ /// # Examples
+ /// ```no_run
+ /// use dungeon::Dungeon;
+ /// use graphics::Window;
+ /// let mut window = Window::new(800, 600, "Dungeon Crawl");
+ /// let mut renderer = window.renderer();
+ /// let dungeon = Dungeon::new();
+ /// renderer.draw_frame(&dungeon);
+ /// ```
pub fn draw_frame(&mut self, dungeon: &Dungeon) {
// Clear the background to black
self.clear();