mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-08 12:07:52 -06:00
refactor: move entity-related code into src/entity submodule
This commit is contained in:
@@ -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};
|
||||
|
||||
@@ -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)
|
||||
@@ -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;
|
||||
@@ -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,
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
pub mod blinky;
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user