Skip to content

Commit

Permalink
Fix z scale being 0.0 in breakout example (bevyengine#12439)
Browse files Browse the repository at this point in the history
# Objective

Scaling `z` by anything but `1.0` in 2d can only lead to bugs and
confusion. See bevyengine#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.
  • Loading branch information
rparrett authored Mar 13, 2024
1 parent e282ee1 commit a9ca849
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/games/breakout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod stepping;

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

0 comments on commit a9ca849

Please sign in to comment.