mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
examples: fix (ball->side edge of brick) collision detection in breakout.v
This commit is contained in:
parent
9ae8cc357f
commit
ef6b81d214
1 changed files with 1 additions and 1 deletions
|
@ -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--
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue