/// <summary> /// updates the positions and events /// </summary> /// <param name="canvas">the canvas</param> private void Update(Canvas canvas) { if (bricks.HasBallHit(ball)) { //if there was a hit - play hit sound and increase score AudioManager.Instance.PlaySound(Sound.brick_hit); Score.IncreaseScore(difficulty); } if (bricks.AreOver()) { //if there aren't any bricks left - play sound and refill the bricks AudioManager.Instance.PlaySound(Sound.finished_bricks); bricks.MakeVisible(); Pause(); } BottomBat.UpdateMovement(); //update the bottom bat movement TopBat.UpdateMovement(); //update the bottom bat movement if (flagClick) { ball.UpdateMovement(canvas); //update the ball movement } else { ball.Position = new Vector(BottomBat.Position.X + Bat.Size.X / 2, ball.Position.Y); } BottomBat.UpdateBounds(canvas); //check bounds of the bat TopBat.UpdateBounds(canvas); //check bounds of the bat ball.UpdateWallHit(new Vector(canvas.Width, canvas.Height)); //check bounds of the ball - walls if (BottomBat.IsBallHit(ball, canvas) == 1 || TopBat.IsBallHit(ball, canvas) == 1) { // if the bat hit the ball - play sound AudioManager.Instance.PlaySound(Sound.bat_hit); } else if (BottomBat.IsBallHit(ball, canvas) == -1 || TopBat.IsBallHit(ball, canvas) == -1) { // if the bat missed the ball - the player lost HasLost = true; } }