summaryrefslogtreecommitdiff
path: root/graphics/src/render.rs
diff options
context:
space:
mode:
authoralf9310 <alf9310@rit.edu>2025-10-17 14:34:19 -0400
committeralf9310 <alf9310@rit.edu>2025-10-17 14:34:19 -0400
commita4538b90420f159b4449c80739fb208ec1c01d70 (patch)
tree65275ee11f2cf109c73647dd8e57c8d15a4b9e1c /graphics/src/render.rs
parentGame name (diff)
downloadDungeonCrawl-a4538b90420f159b4449c80739fb208ec1c01d70.tar.gz
DungeonCrawl-a4538b90420f159b4449c80739fb208ec1c01d70.tar.bz2
DungeonCrawl-a4538b90420f159b4449c80739fb208ec1c01d70.zip
Added render documentation
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();