feat: atlas tile color modulation

This commit is contained in:
2025-07-26 15:06:27 -05:00
parent 9066b2cdbc
commit a1d37a1a0b
12 changed files with 80 additions and 78 deletions

View File

@@ -37,28 +37,28 @@ impl DirectionalAnimatedTexture {
pub fn render(&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,
Direction::Up => &mut self.up,
Direction::Down => &mut self.down,
Direction::Left => &mut self.left,
Direction::Right => &mut self.right,
};
let frame_index = (self.ticker / self.ticks_per_frame) as usize % frames.len();
let tile = &frames[frame_index];
let tile = &mut frames[frame_index];
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,
Direction::Up => &mut self.up,
Direction::Down => &mut self.down,
Direction::Left => &mut self.left,
Direction::Right => &mut self.right,
};
// Show the last frame (full sprite) when stopped
let tile = &frames[1];
let tile = &mut frames[1];
tile.render(canvas, dest)
}