Skip to content

Commit a9ca849

Browse files
authored
Fix z scale being 0.0 in breakout example (#12439)
# Objective Scaling `z` by anything but `1.0` in 2d can only lead to bugs and confusion. See #4149. ## Solution Use a `Vec2` for the paddle size const, and add a scale of `1.0` later. This matches the way `BRICK_SIZE` is defined.
1 parent e282ee1 commit a9ca849

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/games/breakout.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod stepping;
1010

1111
// These constants are defined in `Transform` units.
1212
// Using the default 2D camera they correspond 1:1 with screen pixels.
13-
const PADDLE_SIZE: Vec3 = Vec3::new(120.0, 20.0, 0.0);
13+
const PADDLE_SIZE: Vec2 = Vec2::new(120.0, 20.0);
1414
const GAP_BETWEEN_PADDLE_AND_FLOOR: f32 = 60.0;
1515
const PADDLE_SPEED: f32 = 500.0;
1616
// How close can the paddle get to the wall
@@ -202,7 +202,7 @@ fn setup(
202202
SpriteBundle {
203203
transform: Transform {
204204
translation: Vec3::new(0.0, paddle_y, 0.0),
205-
scale: PADDLE_SIZE,
205+
scale: PADDLE_SIZE.extend(1.0),
206206
..default()
207207
},
208208
sprite: Sprite {

0 commit comments

Comments
 (0)