refactor: remove dead code, move direction & graph into 'map' module

This commit is contained in:
2025-08-16 14:37:14 -05:00
parent 313ca4f3e6
commit d47d70ff5b
27 changed files with 31 additions and 1003 deletions

View File

@@ -1,5 +1,5 @@
use glam::IVec2;
use pacman::entity::direction::*;
use pacman::map::direction::*;
#[test]
fn test_direction_opposite() {

View File

@@ -1,5 +1,5 @@
use pacman::entity::direction::Direction;
use pacman::entity::graph::{Graph, Node, TraversalFlags};
use pacman::map::direction::Direction;
use pacman::map::graph::{Graph, Node, TraversalFlags};
fn create_test_graph() -> Graph {
let mut graph = Graph::new();

View File

@@ -1,19 +0,0 @@
use glam::{IVec2, UVec2};
use pacman::helpers::centered_with_size;
#[test]
fn test_centered_with_size() {
let test_cases = [
((100, 100), (50, 30), (75, 85)),
((50, 50), (51, 31), (25, 35)),
((0, 0), (100, 100), (-50, -50)),
((-100, -50), (80, 40), (-140, -70)),
((1000, 1000), (1000, 1000), (500, 500)),
];
for ((pos_x, pos_y), (size_x, size_y), (expected_x, expected_y)) in test_cases {
let rect = centered_with_size(IVec2::new(pos_x, pos_y), UVec2::new(size_x, size_y));
assert_eq!(rect.origin(), (expected_x, expected_y));
assert_eq!(rect.size(), (size_x, size_y));
}
}

View File

@@ -1,46 +0,0 @@
// use glam::U16Vec2;
// use pacman::texture::sprite::{AtlasTile, Sprite};
// #[test]
// fn test_item_type_get_score() {
// assert_eq!(ItemType::Pellet.get_score(), 10);
// assert_eq!(ItemType::Energizer.get_score(), 50);
// let fruit = ItemType::Fruit { kind: FruitKind::Apple };
// assert_eq!(fruit.get_score(), 100);
// }
// #[test]
// fn test_fruit_kind_increasing_score() {
// // Build a list of fruit kinds, sorted by their index
// let mut kinds = FruitKind::iter()
// .map(|kind| (kind.index(), kind.get_score()))
// .collect::<Vec<_>>();
// kinds.sort_unstable_by_key(|(index, _)| *index);
// assert_eq!(kinds.len(), FruitKind::COUNT);
// // Check that the score increases as expected
// for window in kinds.windows(2) {
// let ((_, prev), (_, next)) = (window[0], window[1]);
// assert!(prev < next, "Fruits should have increasing scores, but {prev:?} < {next:?}");
// }
// }
// #[test]
// fn test_item_creation_and_collection() {
// let atlas_tile = AtlasTile {
// pos: U16Vec2::new(0, 0),
// size: U16Vec2::new(16, 16),
// color: None,
// };
// let sprite = Sprite::new(atlas_tile);
// let mut item = Item::new(0, ItemType::Pellet, sprite);
// assert!(!item.is_collected());
// assert_eq!(item.get_score(), 10);
// assert_eq!(item.position().from_node_id(), 0);
// item.collect();
// assert!(item.is_collected());
// }