private void CheckBallCollision(Ball ball, Wall wall) { var aliveBricks = -1; foreach (Brick brick in wall.Bricks) { if (brick.IsEnabled) { aliveBricks += 1; if (SplashKit.BitmapCircleCollision(brick.CollisionBitmap, brick.X, brick.Y, ball.Circle)) { this.OnCollideWithBrick(EventArgs.Empty); brick.IsEnabled = false; Console.WriteLine(ball.GetType().Name + " hit " + brick.GetType().Name); } } } if (aliveBricks == 0) { IsGameOver = true; } }
private void CheckBallCollision(Ball ball, Bat bat) { if (SplashKit.BitmapCircleCollision(bat.CollisionBitmap, bat.X, bat.Y, ball.Circle)) { this.OnCollideWithBat(EventArgs.Empty); Console.WriteLine(ball.GetType().Name + " hit " + bat.GetType().Name); } }