feat: new edible type for pellet/powerpellet, fruits, separate static/moving entities

This commit is contained in:
2025-07-23 17:16:15 -05:00
parent de1a89b9b0
commit 785a760343
10 changed files with 398 additions and 235 deletions

View File

@@ -10,7 +10,7 @@ use crate::direction::Direction;
/// Trait for drawable atlas-based textures
pub trait FrameDrawn {
fn render(
&mut self,
&self,
canvas: &mut Canvas<Window>,
position: (i32, i32),
direction: Direction,
@@ -63,7 +63,7 @@ impl<'a> AtlasTexture<'a> {
impl<'a> FrameDrawn for AtlasTexture<'a> {
fn render(
&mut self,
&self,
canvas: &mut Canvas<Window>,
position: (i32, i32),
direction: Direction,
@@ -158,18 +158,13 @@ impl<'a> AnimatedAtlasTexture<'a> {
impl<'a> FrameDrawn for AnimatedAtlasTexture<'a> {
fn render(
&mut self,
&self,
canvas: &mut Canvas<Window>,
position: (i32, i32),
direction: Direction,
frame: Option<u32>,
) {
self.atlas.render(
canvas,
position,
direction,
frame.or(Some(self.current_frame())),
);
self.tick();
let frame = frame.unwrap_or_else(|| self.current_frame());
self.atlas.render(canvas, position, direction, Some(frame));
}
}