summaryrefslogtreecommitdiff
path: root/graphics/src/render.rs
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-10-18 13:21:40 -0400
committerFreya Murphy <freya@freyacat.org>2025-10-18 13:21:40 -0400
commit8e7268c661e8df25224c907ba68eeb5a9cc5ff11 (patch)
tree27db2f024ae85d95ca5ba7ead9e637ac3c9c9ee7 /graphics/src/render.rs
parentgraphics: remove anyhow (it was not being used) (diff)
downloadDungeonCrawl-8e7268c661e8df25224c907ba68eeb5a9cc5ff11.tar.gz
DungeonCrawl-8e7268c661e8df25224c907ba68eeb5a9cc5ff11.tar.bz2
DungeonCrawl-8e7268c661e8df25224c907ba68eeb5a9cc5ff11.zip
graphics: add audio/texture subsytem
Diffstat (limited to 'graphics/src/render.rs')
-rw-r--r--graphics/src/render.rs28
1 files changed, 16 insertions, 12 deletions
diff --git a/graphics/src/render.rs b/graphics/src/render.rs
index 8bde77d..d9b0473 100644
--- a/graphics/src/render.rs
+++ b/graphics/src/render.rs
@@ -8,21 +8,28 @@ use raylib::{
prelude::{RaylibDraw, RaylibDrawHandle, RaylibHandle},
};
+use crate::assets::ImageData;
+
/// The `FrameInfo` struct contains information about
/// the current frame being rendered.
-pub struct FrameInfo {
+pub struct FrameInfo<'a> {
/// Time in seconds since last frame drawn
pub delta: f32,
/// FPS for last frame drawn
pub fps: u32,
+ /// Loaded texture data
+ /// NOTE: remove `expect` once we start using image data!!
+ #[expect(dead_code)]
+ pub(crate) image: &'a ImageData,
}
-impl FrameInfo {
+impl<'a> FrameInfo<'a> {
/// Creates a new `FrameInfo` from the provided
/// `RaylibHandle`.
- pub fn new(handle: &RaylibHandle) -> Self {
+ pub(crate) fn new(handle: &RaylibHandle, image: &'a ImageData) -> Self {
Self {
delta: handle.get_frame_time(),
fps: handle.get_fps(),
+ image,
}
}
}
@@ -31,16 +38,16 @@ impl FrameInfo {
/// frame of the game. It is created per frame.
pub struct Renderer<'a> {
handle: RaylibDrawHandle<'a>,
- info: FrameInfo,
+ info: FrameInfo<'a>,
}
impl<'a> Renderer<'a> {
/// Creates the renderer for the current frame
- pub(crate) fn new(handle: RaylibDrawHandle<'a>, info: FrameInfo) -> Self {
+ pub(crate) fn new(handle: RaylibDrawHandle<'a>, info: FrameInfo<'a>) -> Self {
Self { handle, info }
}
/// Returns the info struct for the current frame
- pub fn info(&self) -> &FrameInfo {
+ pub fn info(&self) -> &FrameInfo<'a> {
&self.info
}
@@ -70,7 +77,7 @@ impl<'a> Renderer<'a> {
/// ```no_run
/// use dungeon::Dungeon;
/// use graphics::Window;
- /// let mut window = Window::new(800, 600, "Dungeon Crawl");
+ /// let mut window = Window::new(800, 600, "Dungeon Crawl").unwrap();
/// let mut renderer = window.renderer();
/// let dungeon = Dungeon::new();
/// renderer.draw_frame(&dungeon);
@@ -94,22 +101,19 @@ impl<'a> Renderer<'a> {
self.draw_fps();
}
- /// Draw game over screen
- pub fn draw_game_over(&mut self) {
- // TODO:
- }
-
/// Draw the player sprite
pub fn draw_player(&mut self, player: &Player) {
self.draw_entity(&player.entity);
}
/// Draws an entity
+ #[expect(clippy::unused_self)]
pub fn draw_entity(&mut self, _entity: &Entity) {
// TODO:
}
/// Draw dungeon tiles
+ #[expect(clippy::unused_self)]
pub fn draw_tiles(&mut self, _dungeon: &Dungeon) {
// TODO:
}