diff options
| author | Freya Murphy <freya@freyacat.org> | 2025-10-23 13:09:39 -0400 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2025-10-23 13:12:18 -0400 |
| commit | 996805bf576343e9620a875454d2e35e8e54170c (patch) | |
| tree | 9c15d3d0e4d59b3f5bf46978bce2e8677d9cd589 /graphics/src/assets.rs | |
| parent | dungeon: add hash to to check if it has been changed (diff) | |
| download | DungeonCrawl-996805bf576343e9620a875454d2e35e8e54170c.tar.gz DungeonCrawl-996805bf576343e9620a875454d2e35e8e54170c.tar.bz2 DungeonCrawl-996805bf576343e9620a875454d2e35e8e54170c.zip | |
graphics: refactor Assets, and add tile drawing!
Diffstat (limited to 'graphics/src/assets.rs')
| -rw-r--r-- | graphics/src/assets.rs | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/graphics/src/assets.rs b/graphics/src/assets.rs index 3f2354a..edac69b 100644 --- a/graphics/src/assets.rs +++ b/graphics/src/assets.rs @@ -1,8 +1,6 @@ //! The `assets` crate stores all audio and image assets that need to be //! loaded during runtime -use std::error::Error; - use raylib::{RaylibHandle, RaylibThread, audio::RaylibAudio}; #[expect(dead_code)] @@ -14,7 +12,7 @@ type Sound = raylib::audio::Sound<'static>; #[derive(Debug)] pub struct AudioData {} impl AudioData { - pub(crate) fn load() -> Result<Self, Box<dyn Error>> { + pub(crate) fn load() -> crate::Result<Self> { // Phantom handle to the raylib audio subsystem // Raylib doesnt use a handle, but the rust bindings // have one to ensure memory safety. @@ -41,7 +39,7 @@ impl ImageData { pub(crate) fn load( _handle: &mut RaylibHandle, _thread: &RaylibThread, - ) -> Result<Self, Box<dyn Error>> { + ) -> crate::Result<Self> { // TODO: load image data //let example = handle.load_texture(&thread, "example.png"); @@ -49,22 +47,3 @@ impl ImageData { Ok(Self {}) } } - -#[derive(Debug)] -pub(crate) struct Assets { - /// Audio needs to be accessible outside of the renderer - pub(crate) audio: AudioData, - /// Images are only needed by the renderer - pub(crate) image: ImageData, -} -impl Assets { - pub(crate) fn load( - handle: &mut RaylibHandle, - thread: &RaylibThread, - ) -> Result<Self, Box<dyn Error>> { - let audio = AudioData::load()?; - let image = ImageData::load(handle, thread)?; - - Ok(Self { audio, image }) - } -} |