diff --git a/examples/game/breakout.rs b/examples/game/breakout.rs index 444baf75958346..9cfdfb84481363 100644 --- a/examples/game/breakout.rs +++ b/examples/game/breakout.rs @@ -6,6 +6,7 @@ use bevy::{ }; /// An implementation of the classic game "Breakout" +const TIME_STEP: f32 = 1.0 / 60.0; fn main() { App::build() .add_plugins(DefaultPlugins) @@ -15,7 +16,7 @@ fn main() { .add_stage( FixedUpdateStage, SystemStage::parallel() - .with_run_criteria(FixedTimestep::step(1.0 / 60.0)) + .with_run_criteria(FixedTimestep::step(TIME_STEP as f64)) .with_system(paddle_movement_system.system()) .with_system(ball_collision_system.system()) .with_system(ball_movement_system.system()), @@ -62,7 +63,7 @@ fn setup( sprite: Sprite::new(Vec2::new(120.0, 30.0)), ..Default::default() }) - .with(Paddle { speed: 8.0 }) + .with(Paddle { speed: 500.0 }) .with(Collider::Paddle) // ball .spawn(SpriteBundle { @@ -72,7 +73,7 @@ fn setup( ..Default::default() }) .with(Ball { - velocity: 6.0 * Vec3::new(0.5, -0.5, 0.0).normalize(), + velocity: 400.0 * Vec3::new(0.5, -0.5, 0.0).normalize(), }) // scoreboard .spawn(TextBundle { @@ -194,7 +195,7 @@ fn paddle_movement_system( let translation = &mut transform.translation; // move the paddle horizontally - translation.x += direction * paddle.speed; + translation.x += direction * paddle.speed * TIME_STEP; // bound the paddle within the walls translation.x = translation.x.min(380.0).max(-380.0); } @@ -202,7 +203,7 @@ fn paddle_movement_system( fn ball_movement_system(mut ball_query: Query<(&Ball, &mut Transform)>) { if let Ok((ball, mut transform)) = ball_query.single_mut() { - transform.translation += ball.velocity; + transform.translation += ball.velocity * TIME_STEP; } }