diff --git a/src/debug.rs b/src/debug.rs index fce6184..44bbdf5 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -1,7 +1,7 @@ //! Debug rendering utilities for Pac-Man. use crate::{ constants::{MapTile, BOARD_HEIGHT, BOARD_WIDTH}, - ghosts::blinky::Blinky, + entity::blinky::Blinky, map::Map, }; use glam::{IVec2, UVec2}; diff --git a/src/ghosts/blinky.rs b/src/entity/blinky.rs similarity index 94% rename from src/ghosts/blinky.rs rename to src/entity/blinky.rs index 4815f34..7245571 100644 --- a/src/ghosts/blinky.rs +++ b/src/entity/blinky.rs @@ -5,10 +5,10 @@ use sdl2::render::{Canvas, Texture}; use sdl2::video::Window; use crate::direction::Direction; +use crate::entity::ghost::{Ghost, GhostMode, GhostType}; +use crate::entity::pacman::Pacman; use crate::entity::{Entity, Moving, Renderable, StaticEntity}; -use crate::ghost::{Ghost, GhostMode, GhostType}; use crate::map::Map; -use crate::pacman::Pacman; use glam::{IVec2, UVec2}; pub struct Blinky<'a> { @@ -29,7 +29,7 @@ impl<'a> Blinky<'a> { } /// Gets Blinky's chase target - directly targets Pac-Man's current position - fn get_chase_target(&self) -> IVec2 { + pub fn get_chase_target(&self) -> IVec2 { let pacman = self.ghost.pacman.borrow(); let cell = pacman.base().cell_position; IVec2::new(cell.x as i32, cell.y as i32) diff --git a/src/ghost.rs b/src/entity/ghost.rs similarity index 99% rename from src/ghost.rs rename to src/entity/ghost.rs index 8cbb0b5..dfe4817 100644 --- a/src/ghost.rs +++ b/src/entity/ghost.rs @@ -5,10 +5,10 @@ use rand::SeedableRng; use crate::animation::{AnimatedAtlasTexture, FrameDrawn}; use crate::constants::{MapTile, BOARD_WIDTH}; use crate::direction::Direction; +use crate::entity::pacman::Pacman; use crate::entity::{Entity, MovableEntity, Moving, Renderable}; use crate::map::Map; use crate::modulation::{SimpleTickModulator, TickModulator}; -use crate::pacman::Pacman; use glam::{IVec2, UVec2}; use sdl2::pixels::Color; use sdl2::render::Texture; diff --git a/src/entity.rs b/src/entity/mod.rs similarity index 99% rename from src/entity.rs rename to src/entity/mod.rs index 08b1967..c80028d 100644 --- a/src/entity.rs +++ b/src/entity/mod.rs @@ -1,3 +1,7 @@ +pub mod blinky; +pub mod ghost; +pub mod pacman; + use crate::{ constants::{MapTile, BOARD_OFFSET, BOARD_WIDTH, CELL_SIZE}, direction::Direction, diff --git a/src/pacman.rs b/src/entity/pacman.rs similarity index 100% rename from src/pacman.rs rename to src/entity/pacman.rs diff --git a/src/game.rs b/src/game.rs index 838e47e..0f84802 100644 --- a/src/game.rs +++ b/src/game.rs @@ -22,10 +22,10 @@ use crate::constants::RAW_BOARD; use crate::debug::{DebugMode, DebugRenderer}; use crate::direction::Direction; use crate::edible::{reconstruct_edibles, Edible, EdibleKind}; +use crate::entity::blinky::Blinky; +use crate::entity::pacman::Pacman; use crate::entity::Renderable; -use crate::ghosts::blinky::Blinky; use crate::map::Map; -use crate::pacman::Pacman; /// The main game state. /// @@ -232,7 +232,7 @@ impl<'a> Game<'a> { self.blinky.base.base.cell_position = *pos; self.blinky.base.in_tunnel = false; self.blinky.base.direction = Direction::Left; - self.blinky.mode = crate::ghost::GhostMode::Chase; + self.blinky.mode = crate::entity::ghost::GhostMode::Chase; } } diff --git a/src/ghosts/mod.rs b/src/ghosts/mod.rs deleted file mode 100644 index 6dc5c58..0000000 --- a/src/ghosts/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod blinky; diff --git a/src/main.rs b/src/main.rs index 8fdcca6..5bb8110 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,12 +63,9 @@ mod edible; mod emscripten; mod entity; mod game; -mod ghost; -mod ghosts; mod helper; mod map; mod modulation; -mod pacman; #[cfg(not(target_os = "emscripten"))] fn sleep(value: Duration) {