Workshop › Puzzle Bobble-style Bubble Shooter › Step 12 of 31
Past the left or right wall, the bubble bounces: vx flips and the bubble is put back inside. Bank shots off the walls are a
big part of the game.
```js
if (shot.x < R || shot.x > canvas.width - R) {
shot.vx = -shot.vx // bounce off the side walls
shot.x = Math.max(R, Math.min(canvas.width - R, shot.x))
}
```R to it.-shot.vx reverses the sideways speed; the position is clamped back between R and canvas.width - R.In update, under shot.y += shot.vy, write the if block.
Skills: Velocity and gravity, Collision detection