mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-15 04:12:34 -06:00
chore: remove LevelTiming resource
This commit is contained in:
15
src/game.rs
15
src/game.rs
@@ -18,8 +18,8 @@ use crate::systems::{
|
||||
ghost_movement_system, hud_render_system, item_system, profile, ready_visibility_system, render_system, AudioEvent,
|
||||
AudioResource, AudioState, BackbufferResource, Collider, DebugFontResource, DebugState, DebugTextureResource, DeltaTime,
|
||||
DirectionalAnimated, EntityType, Frozen, Ghost, GhostBundle, GhostCollider, GlobalState, ItemBundle, ItemCollider,
|
||||
LevelTiming, MapTextureResource, PacmanCollider, PlayerBundle, PlayerControlled, PlayerStateBundle, Renderable,
|
||||
ScoreResource, StartupSequence, SystemTimings,
|
||||
MapTextureResource, PacmanCollider, PlayerBundle, PlayerControlled, PlayerStateBundle, Renderable, ScoreResource,
|
||||
StartupSequence, SystemTimings,
|
||||
};
|
||||
use crate::texture::animated::AnimatedTexture;
|
||||
use bevy_ecs::event::EventRegistry;
|
||||
@@ -227,7 +227,6 @@ impl Game {
|
||||
world.insert_resource(DebugState::default());
|
||||
world.insert_resource(AudioState::default());
|
||||
world.insert_resource(CursorPosition::default());
|
||||
world.insert_resource(LevelTiming::for_level(1));
|
||||
|
||||
world.add_observer(
|
||||
|event: Trigger<GameEvent>, mut state: ResMut<GlobalState>, _score: ResMut<ScoreResource>| {
|
||||
@@ -295,15 +294,7 @@ impl Game {
|
||||
.chain(),
|
||||
));
|
||||
|
||||
// Initialize StartupSequence as a global resource
|
||||
let ready_duration_ticks = {
|
||||
let duration = world
|
||||
.get_resource::<LevelTiming>()
|
||||
.map(|t| t.spawn_freeze_duration)
|
||||
.unwrap_or(1.5);
|
||||
(duration * 60.0) as u32 // Convert to ticks at 60 FPS
|
||||
};
|
||||
world.insert_resource(StartupSequence::new(ready_duration_ticks, 60));
|
||||
world.insert_resource(StartupSequence::new(60 * 3, 60));
|
||||
|
||||
// Spawn ghosts
|
||||
Self::spawn_ghosts(&mut world)?;
|
||||
|
||||
@@ -141,35 +141,6 @@ impl Default for MovementModifiers {
|
||||
}
|
||||
}
|
||||
|
||||
/// Level-dependent timing configuration
|
||||
#[derive(Resource, Debug, Clone, Copy)]
|
||||
pub struct LevelTiming {
|
||||
/// Duration of energizer effect in seconds
|
||||
pub energizer_duration: f32,
|
||||
/// Freeze duration at spawn/ready in seconds
|
||||
pub spawn_freeze_duration: f32,
|
||||
/// When to start flashing relative to energizer end (seconds)
|
||||
pub energizer_flash_threshold: f32,
|
||||
}
|
||||
|
||||
impl Default for LevelTiming {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
energizer_duration: 6.0,
|
||||
spawn_freeze_duration: 1.5,
|
||||
energizer_flash_threshold: 2.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LevelTiming {
|
||||
/// Returns timing configuration for a given level.
|
||||
pub fn for_level(_level: u32) -> Self {
|
||||
// Placeholder: tune per the Pac-Man Dossier tables
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// Tag component for entities that should be frozen during startup
|
||||
#[derive(Component, Debug, Clone, Copy)]
|
||||
pub struct Frozen;
|
||||
|
||||
@@ -7,7 +7,7 @@ use bevy_ecs::{
|
||||
|
||||
use crate::{
|
||||
events::GameEvent,
|
||||
systems::{AudioEvent, EntityType, GhostCollider, ItemCollider, LevelTiming, PacmanCollider, ScoreResource, Vulnerable},
|
||||
systems::{AudioEvent, EntityType, GhostCollider, ItemCollider, PacmanCollider, ScoreResource, Vulnerable},
|
||||
};
|
||||
|
||||
/// Determines if a collision between two entity types should be handled by the item system.
|
||||
@@ -29,7 +29,6 @@ pub fn item_system(
|
||||
item_query: Query<(Entity, &EntityType), With<ItemCollider>>,
|
||||
ghost_query: Query<Entity, With<GhostCollider>>,
|
||||
mut events: EventWriter<AudioEvent>,
|
||||
level_timing: Res<LevelTiming>,
|
||||
) {
|
||||
for event in collision_events.read() {
|
||||
if let GameEvent::Collision(entity1, entity2) = event {
|
||||
@@ -58,7 +57,7 @@ pub fn item_system(
|
||||
// Make ghosts vulnerable when power pellet is collected
|
||||
if *entity_type == EntityType::PowerPellet {
|
||||
// Convert seconds to frames (assumes 60 FPS)
|
||||
let total_ticks = (level_timing.energizer_duration * 60.0).round().clamp(0.0, u32::MAX as f32) as u32;
|
||||
let total_ticks = 60 * 5;
|
||||
|
||||
// Add Vulnerable component to all ghosts
|
||||
for ghost_entity in ghost_query.iter() {
|
||||
|
||||
Reference in New Issue
Block a user