diff --git a/examples/games/breakout.rs b/examples/games/breakout.rs index 3cc19c5a7f..5b62d81a92 100644 --- a/examples/games/breakout.rs +++ b/examples/games/breakout.rs @@ -58,7 +58,7 @@ fn main() { .add_schedule(FixedUpdate) .at(Val::Percent(35.0), Val::Percent(50.0)), ) - .insert_resource(Scoreboard { score: 0 }) + .insert_resource(Score(0)) .insert_resource(ClearColor(BACKGROUND_COLOR)) .add_event::() .add_systems(Startup, setup) @@ -97,7 +97,7 @@ struct CollisionEvent; #[derive(Component)] struct Brick; -#[derive(Resource)] +#[derive(Resource, Deref)] struct CollisionSound(Handle); // This bundle is a collection of the components that define a "wall" in our game @@ -118,6 +118,7 @@ enum WallLocation { } impl WallLocation { + /// Location of the *center* of the wall, used in `transform.translation()` fn position(&self) -> Vec2 { match self { WallLocation::Left => Vec2::new(LEFT_WALL, 0.), @@ -127,6 +128,7 @@ impl WallLocation { } } + /// (x, y) dimensions of the wall, used in `transform.scale()` fn size(&self) -> Vec2 { let arena_height = TOP_WALL - BOTTOM_WALL; let arena_width = RIGHT_WALL - LEFT_WALL; @@ -173,10 +175,8 @@ impl WallBundle { } // This resource tracks the game's score -#[derive(Resource)] -struct Scoreboard { - score: usize, -} +#[derive(Resource, Deref, DerefMut)] +struct Score(usize); #[derive(Component)] struct ScoreboardUi; @@ -350,27 +350,26 @@ fn apply_velocity(mut query: Query<(&mut Transform, &Velocity)>, time: Res