Skip to content

Commit ab83336

Browse files
Replace _system system names in Breakout examples (#4312)
# Objective - The Breakout example uses system names like `paddle_movement_system` - _system syntax is redundant - the [community has spoken](#2804), and prefers to avoid `_system` system names by a more than 2:1 ratio - existing system names were not terribly descriptive ## Solution - rename the systems to take the form of `verb`, rather than `noun_system` to better capture the behavior they are implenting - yeet `_system`
1 parent 207ebde commit ab83336

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

examples/game/breakout.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ fn main() {
5252
.add_system_set(
5353
SystemSet::new()
5454
.with_run_criteria(FixedTimestep::step(TIME_STEP as f64))
55-
.with_system(paddle_movement_system)
56-
.with_system(ball_collision_system)
57-
.with_system(apply_velocity_system),
55+
.with_system(move_paddle)
56+
.with_system(check_for_collisions)
57+
.with_system(apply_velocity),
5858
)
59-
.add_system(scoreboard_system)
59+
.add_system(update_scoreboard)
6060
.add_system(bevy::input::system::exit_on_esc_system)
6161
.run();
6262
}
@@ -252,7 +252,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
252252
}
253253
}
254254

255-
fn paddle_movement_system(
255+
fn move_paddle(
256256
keyboard_input: Res<Input<KeyCode>>,
257257
mut query: Query<&mut Transform, With<Paddle>>,
258258
) {
@@ -273,19 +273,19 @@ fn paddle_movement_system(
273273
translation.x = translation.x.min(PADDLE_BOUNDS).max(-PADDLE_BOUNDS);
274274
}
275275

276-
fn apply_velocity_system(mut query: Query<(&mut Transform, &Velocity)>) {
276+
fn apply_velocity(mut query: Query<(&mut Transform, &Velocity)>) {
277277
for (mut transform, velocity) in query.iter_mut() {
278278
transform.translation.x += velocity.0.x * TIME_STEP;
279279
transform.translation.y += velocity.0.y * TIME_STEP;
280280
}
281281
}
282282

283-
fn scoreboard_system(scoreboard: Res<Scoreboard>, mut query: Query<&mut Text>) {
283+
fn update_scoreboard(scoreboard: Res<Scoreboard>, mut query: Query<&mut Text>) {
284284
let mut text = query.single_mut();
285285
text.sections[1].value = format!("{}", scoreboard.score);
286286
}
287287

288-
fn ball_collision_system(
288+
fn check_for_collisions(
289289
mut commands: Commands,
290290
mut scoreboard: ResMut<Scoreboard>,
291291
mut ball_query: Query<(&mut Velocity, &Transform), With<Ball>>,

0 commit comments

Comments
 (0)