mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-16 22:12:36 -06:00
refactor: remove dead code, move direction & graph into 'map' module
This commit is contained in:
@@ -2,7 +2,7 @@ use bevy_ecs::{bundle::Bundle, component::Component, resource::Resource};
|
||||
use bitflags::bitflags;
|
||||
|
||||
use crate::{
|
||||
entity::graph::TraversalFlags,
|
||||
map::graph::TraversalFlags,
|
||||
systems::movement::{BufferedDirection, Position, Velocity},
|
||||
texture::{animated::AnimatedTexture, sprite::AtlasTile},
|
||||
};
|
||||
@@ -41,6 +41,7 @@ impl Ghost {
|
||||
}
|
||||
|
||||
/// Returns the ghost's color for debug rendering.
|
||||
#[allow(dead_code)]
|
||||
pub fn debug_color(&self) -> sdl2::pixels::Color {
|
||||
match self {
|
||||
Ghost::Blinky => sdl2::pixels::Color::RGB(255, 0, 0), // Red
|
||||
|
||||
@@ -3,8 +3,11 @@ use rand::prelude::*;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use crate::{
|
||||
entity::{direction::Direction, graph::Edge},
|
||||
map::builder::Map,
|
||||
map::{
|
||||
builder::Map,
|
||||
direction::Direction,
|
||||
graph::{Edge, TraversalFlags},
|
||||
},
|
||||
systems::{
|
||||
components::{DeltaTime, Ghost},
|
||||
movement::{Position, Velocity},
|
||||
@@ -32,9 +35,7 @@ pub fn ghost_movement_system(
|
||||
|
||||
// Collect all available directions that ghosts can traverse
|
||||
for edge in Direction::DIRECTIONS.iter().flat_map(|d| intersection.get(*d)) {
|
||||
if edge.traversal_flags.contains(crate::entity::graph::TraversalFlags::GHOST)
|
||||
&& edge.direction != opposite
|
||||
{
|
||||
if edge.traversal_flags.contains(TraversalFlags::GHOST) && edge.direction != opposite {
|
||||
non_opposite_options.push(edge);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ use sdl2::{event::Event, keyboard::Keycode, EventPump};
|
||||
|
||||
use crate::systems::components::DeltaTime;
|
||||
use crate::{
|
||||
entity::direction::Direction,
|
||||
events::{GameCommand, GameEvent},
|
||||
map::direction::Direction,
|
||||
};
|
||||
|
||||
#[derive(Resource, Default, Debug, Copy, Clone)]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::entity::direction::Direction;
|
||||
use crate::entity::graph::Graph;
|
||||
use crate::error::{EntityError, GameResult};
|
||||
use crate::map::direction::Direction;
|
||||
use crate::map::graph::Graph;
|
||||
use bevy_ecs::component::Component;
|
||||
use glam::Vec2;
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ use bevy_ecs::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
entity::graph::Edge,
|
||||
error::GameError,
|
||||
events::{GameCommand, GameEvent},
|
||||
map::builder::Map,
|
||||
map::graph::Edge,
|
||||
systems::{
|
||||
components::{AudioState, DeltaTime, EntityType, GlobalState, PlayerControlled},
|
||||
debug::DebugState,
|
||||
|
||||
@@ -7,6 +7,7 @@ use bevy_ecs::entity::Entity;
|
||||
use bevy_ecs::event::EventWriter;
|
||||
use bevy_ecs::prelude::{Changed, Or, RemovedComponents};
|
||||
use bevy_ecs::system::{NonSendMut, Query, Res, ResMut};
|
||||
use sdl2::rect::{Point, Rect};
|
||||
use sdl2::render::{Canvas, Texture};
|
||||
use sdl2::video::Window;
|
||||
|
||||
@@ -99,9 +100,10 @@ pub fn render_system(
|
||||
let pos = position.get_pixel_position(&map.graph);
|
||||
match pos {
|
||||
Ok(pos) => {
|
||||
let dest = crate::helpers::centered_with_size(
|
||||
glam::IVec2::new(pos.x as i32, pos.y as i32),
|
||||
glam::UVec2::new(renderable.sprite.size.x as u32, renderable.sprite.size.y as u32),
|
||||
let dest = Rect::from_center(
|
||||
Point::from((pos.x as i32, pos.y as i32)),
|
||||
renderable.sprite.size.x as u32,
|
||||
renderable.sprite.size.y as u32,
|
||||
);
|
||||
|
||||
renderable
|
||||
|
||||
Reference in New Issue
Block a user