mirror of
https://github.com/Xevion/Pac-Man.git
synced 2026-01-31 02:25:04 -06:00
refactor: restructure game logic and state management into separate modules
- Moved game logic from `game.rs` to `game/mod.rs` and `game/state.rs` for better organization. - Updated `App` to utilize the new `Game` struct and its state management. - Refactored error handling - Removed unused audio subsystem references
This commit is contained in:
+4
-3
@@ -1,5 +1,6 @@
|
||||
use glam::U16Vec2;
|
||||
use pacman::texture::animated::{AnimatedTexture, AnimatedTextureError};
|
||||
use pacman::error::{AnimatedTextureError, GameError, TextureError};
|
||||
use pacman::texture::animated::AnimatedTexture;
|
||||
use pacman::texture::sprite::AtlasTile;
|
||||
use sdl2::pixels::Color;
|
||||
|
||||
@@ -17,12 +18,12 @@ fn test_animated_texture_creation_errors() {
|
||||
|
||||
assert!(matches!(
|
||||
AnimatedTexture::new(tiles.clone(), 0.0).unwrap_err(),
|
||||
AnimatedTextureError::InvalidFrameDuration(0.0)
|
||||
GameError::Texture(TextureError::Animated(AnimatedTextureError::InvalidFrameDuration(0.0)))
|
||||
));
|
||||
|
||||
assert!(matches!(
|
||||
AnimatedTexture::new(tiles, -0.1).unwrap_err(),
|
||||
AnimatedTextureError::InvalidFrameDuration(-0.1)
|
||||
GameError::Texture(TextureError::Animated(AnimatedTextureError::InvalidFrameDuration(-0.1)))
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -10,15 +10,4 @@ fn test_game_map_creation() {
|
||||
|
||||
assert!(map.graph.node_count() > 0);
|
||||
assert!(!map.grid_to_node.is_empty());
|
||||
|
||||
// Should find Pac-Man's starting position
|
||||
let pacman_pos = map.find_starting_position(0);
|
||||
assert!(pacman_pos.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_game_score_initialization() {
|
||||
// This would require creating a full Game instance, but we can test the concept
|
||||
let map = Map::new(RAW_BOARD).unwrap();
|
||||
assert!(map.find_starting_position(0).is_some());
|
||||
}
|
||||
|
||||
+1
-14
@@ -1,5 +1,5 @@
|
||||
use glam::Vec2;
|
||||
use pacman::constants::{BOARD_CELL_SIZE, CELL_SIZE, RAW_BOARD};
|
||||
use pacman::constants::{CELL_SIZE, RAW_BOARD};
|
||||
use pacman::map::Map;
|
||||
use sdl2::render::Texture;
|
||||
|
||||
@@ -21,19 +21,6 @@ fn test_map_creation() {
|
||||
assert!(has_connections);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_map_starting_positions() {
|
||||
let map = Map::new(RAW_BOARD).unwrap();
|
||||
|
||||
let pacman_pos = map.find_starting_position(0);
|
||||
assert!(pacman_pos.is_some());
|
||||
assert!(pacman_pos.unwrap().x < BOARD_CELL_SIZE.x);
|
||||
assert!(pacman_pos.unwrap().y < BOARD_CELL_SIZE.y);
|
||||
|
||||
let nonexistent_pos = map.find_starting_position(99);
|
||||
assert_eq!(nonexistent_pos, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_map_node_positions() {
|
||||
let map = Map::new(RAW_BOARD).unwrap();
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
use pacman::constants::{BOARD_CELL_SIZE, RAW_BOARD};
|
||||
use pacman::map::parser::{MapTileParser, ParseError};
|
||||
use pacman::error::ParseError;
|
||||
use pacman::map::parser::MapTileParser;
|
||||
|
||||
#[test]
|
||||
fn test_parse_character() {
|
||||
|
||||
Reference in New Issue
Block a user