Workshop › Breakout › Step 20 of 39
A ball that hits a brick from the side should bounce sideways, not up or down. The ball's center tells us which face it came through.
```js
const throughTopOrBottom = ball.x >= brick.x && ball.x <= brick.x + BRICK_W
if (throughTopOrBottom) ball.vy = -ball.vy
else ball.vx = -ball.vx
```throughTopOrBottom is true when the center is between the brick's left and right edges.else runs when the if condition is false: a side hit flips vx instead.In the if (brick) block, replace ball.vy = -ball.vy with the three new lines.
Skills: Collision detection
← Break a brick Wait on the paddle →