public formGame() { InitializeComponent(); /* Loads the width and height of the gameboard which is used to * determine all conditions and limits. Therefore, the game should still work * if the gameboard size was changed*/ boardSizeX = (uint)pboxGameboard.Size.Width; boardSizeY = (uint)pboxGameboard.Size.Height; //Initializing the paddle and ball with gameboard size and paddle size information leftPaddle = new Vertical_Block(paddleDistance, (boardSizeY / 2) - (paddleHeight / 2), paddleWidth, paddleHeight, boardSizeY - paddleHeight, false); rightPaddle = new Vertical_Block(boardSizeX - paddleDistance - paddleWidth, (boardSizeY / 2) - (paddleHeight / 2), paddleWidth, paddleHeight, boardSizeY - paddleHeight, true); ball = new Ball(boardSizeX, boardSizeY, ballSize, paddleDistance, paddleWidth, paddleHeight); //Makes all labels transparent and proportional to gameboard size //Font size must still be changed manually graphicsSettings(); //Initialize and start the timer setTimer(); timeInterval.Start(); //Start the ball towards the left player ball.ballLaunch(1); }
//Default position at the begining of the game public void restart() { lblWinMessage.Text = ""; leftPaddle.Score = 0; rightPaddle.Score = 0; //Always moves ball towards right when restarting leftPaddle.BallDirection = false; rightPaddle.BallDirection = true; displayScore(); ball.ballLaunch(1); ball.RoundTimeElapsed = 0; timeInterval.Start(); }