refactor: huge refactor into atlas-based resources

This commit is contained in:
2025-07-26 12:20:04 -05:00
parent 6ca2e01fba
commit 8e5ec9fef0
17 changed files with 1700 additions and 463 deletions

View File

@@ -1,6 +1,5 @@
//! This module provides a simple animation and atlas system for textures.
use anyhow::Result;
use glam::IVec2;
use sdl2::render::WindowCanvas;
use crate::texture::sprite::AtlasTile;

View File

@@ -1,6 +1,5 @@
//! A texture that blinks on/off for a specified number of ticks.
use anyhow::Result;
use glam::IVec2;
use sdl2::render::WindowCanvas;
use crate::texture::animated::AnimatedTexture;

View File

@@ -2,7 +2,6 @@
use crate::entity::direction::Direction;
use crate::texture::sprite::AtlasTile;
use anyhow::Result;
use glam::IVec2;
use sdl2::render::WindowCanvas;
pub struct DirectionalAnimatedTexture {
@@ -49,4 +48,18 @@ impl DirectionalAnimatedTexture {
tile.render(canvas, dest)
}
pub fn render_stopped(&mut self, canvas: &mut WindowCanvas, dest: sdl2::rect::Rect, direction: Direction) -> Result<()> {
let frames = match direction {
Direction::Up => &self.up,
Direction::Down => &self.down,
Direction::Left => &self.left,
Direction::Right => &self.right,
};
// Show the last frame (full sprite) when stopped
let tile = &frames[1];
tile.render(canvas, dest)
}
}

View File

@@ -1,9 +1,5 @@
use glam::IVec2;
use sdl2::{render::Canvas, video::Window};
use std::rc::Rc;
use crate::entity::direction::Direction;
use crate::texture::sprite::{AtlasTile, SpriteAtlas};
pub mod animated;