examples: fix (ball->side edge of brick) collision detection in breakout.v

This commit is contained in:
Delyan Angelov 2025-03-09 00:41:49 +02:00
parent 9ae8cc357f
commit ef6b81d214
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED

View file

@ -218,7 +218,7 @@ fn (mut g Game) update() {
// Brick collisions // Brick collisions
for mut brick in g.bricks { for mut brick in g.bricks {
if brick.alive && g.ball_y - g.ball_r < brick.y + brick.h && g.ball_y + g.ball_r > brick.y if brick.alive && g.ball_y - g.ball_r < brick.y + brick.h && g.ball_y + g.ball_r > brick.y
&& g.ball_x > brick.x && g.ball_x < brick.x + brick.w { && g.ball_x + g.ball_r > brick.x && g.ball_x - g.ball_r < brick.x + brick.w {
g.play(.brick) g.play(.brick)
brick.alive = false brick.alive = false
g.nbricks-- g.nbricks--