Skip to content

Commit fc32a4d

Browse files
committed
make physics systems dependent on TIME_STEP
1 parent 9a3d5b4 commit fc32a4d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

examples/game/breakout.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ fn main() {
1616
.add_stage(
1717
FixedUpdateStage,
1818
SystemStage::parallel()
19-
.with_run_criteria(
20-
FixedTimestep::step(TIME_STEP as f64)
21-
)
19+
.with_run_criteria(FixedTimestep::step(TIME_STEP as f64))
2220
.with_system(paddle_movement_system.system())
2321
.with_system(ball_collision_system.system())
2422
.with_system(ball_movement_system.system()),
@@ -202,15 +200,15 @@ fn paddle_movement_system(
202200

203201
let translation = &mut transform.translation;
204202
// move the paddle horizontally
205-
translation.x += direction * paddle.speed;
203+
translation.x += direction * paddle.speed * TIME_STEP;
206204
// bound the paddle within the walls
207205
translation.x = translation.x.min(380.0).max(-380.0);
208206
}
209207
}
210208

211209
fn ball_movement_system(mut ball_query: Query<(&Ball, &mut Transform)>) {
212210
if let Ok((ball, mut transform)) = ball_query.single_mut() {
213-
transform.translation += ball.velocity;
211+
transform.translation += ball.velocity * TIME_STEP;
214212
}
215213
}
216214

0 commit comments

Comments
 (0)