refactor: continue improving MovableEntity shared implementation

This commit is contained in:
2025-07-23 15:06:09 -05:00
parent 1fa7a0807f
commit df8f858651
6 changed files with 341 additions and 415 deletions

View File

@@ -4,9 +4,8 @@ use std::rc::Rc;
use sdl2::render::{Canvas, Texture};
use sdl2::video::Window;
use crate::entity::MovableEntity;
use crate::{
entity::Entity,
entity::{Entity, MovableEntity, Renderable},
ghost::{Ghost, GhostMode, GhostType},
map::Map,
pacman::Pacman,
@@ -39,7 +38,7 @@ impl<'a> Blinky<'a> {
/// Gets Blinky's chase target - directly targets Pac-Man's current position
fn get_chase_target(&self) -> (i32, i32) {
let pacman = self.ghost.pacman.borrow();
let cell = pacman.base.cell_position;
let cell = pacman.base().cell_position;
(cell.0 as i32, cell.1 as i32)
}
@@ -48,7 +47,7 @@ impl<'a> Blinky<'a> {
}
pub fn render(&mut self, canvas: &mut Canvas<Window>) {
self.ghost.render(canvas);
Renderable::render(&mut self.ghost, canvas);
}
}

View File

@@ -1,3 +1 @@
mod blinky;
pub use blinky::Blinky;
pub mod blinky;