private void gameTimer_Tick(object sender, EventArgs e) { BreannaPowerUp(); // Move the paddle if (leftArrowDown && paddle.x > 0) { paddle.Move("left"); if (ballStart == false) { ball.MoveWithPaddle("left", paddle); } } if (rightArrowDown && paddle.x < (this.Width - paddle.width)) { paddle.Move("right"); if (ballStart == false) { ball.MoveWithPaddle("right", paddle); } } // Move ball if (ballStart) { ball.Move(); } // Check for collision with top and side walls ball.WallCollision(this); // Check for ball hitting bottom of screen if (ball.BottomCollision(this)) { lives--; if (paddle.width != 80) { paddle.width = 80; } if (ball.xSpeed != 6 && ball.ySpeed != 6) { ball.xSpeed = 6; ball.ySpeed = 6; } // Moves the ball back to origin paddle.x = (this.Width / 2); ball.x = ((paddle.x - (ball.size / 2)) + (paddle.width / 2)); ball.y = (this.Height - paddle.height) - 85; Refresh(); Thread.Sleep(1500); if (lives == 0) { gameTimer.Enabled = false; OnEnd(); } } // Check for collision of ball with paddle, (incl. paddle movement) ball.PaddleCollision(paddle); // Check if ball has collided with any blocks foreach (Block b in blocks) { if (ball.BlockCollision(b)) { b.hp--; score++; if (b.hp == 0) { blocks.Remove(b); } if (blocks.Count == 0) { gameTimer.Enabled = false; Win(); } break; } } //redraw the screen Refresh(); if (gameStart) { Thread.Sleep(1500); gameStart = false; } }