Skip to content

Commit ef6b81d

Browse files
committed
examples: fix (ball->side edge of brick) collision detection in breakout.v
1 parent 9ae8cc3 commit ef6b81d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

examples/breakout/breakout.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ fn (mut g Game) update() {
218218
// Brick collisions
219219
for mut brick in g.bricks {
220220
if brick.alive && g.ball_y - g.ball_r < brick.y + brick.h && g.ball_y + g.ball_r > brick.y
221-
&& g.ball_x > brick.x && g.ball_x < brick.x + brick.w {
221+
&& g.ball_x + g.ball_r > brick.x && g.ball_x - g.ball_r < brick.x + brick.w {
222222
g.play(.brick)
223223
brick.alive = false
224224
g.nbricks--

0 commit comments

Comments
 (0)