private void StartMaxScoreGame()
        {
            var maxScoreGame = new GameModel(selectedFormWidth, selectedFormHeight, ballsCount, playersCountSelection);

            maxScoreGame.SetGameTime(selectedGametime);
            var maxScoreModeForm = new MaxScoreModeForm(maxScoreGame);

            maxScoreModeForm.ShowDialog();
        }
예제 #2
0
        public void Should_CreateNewFormWithCertainWidthAndHeight()
        {
            var random   = new Random();
            var width    = random.Next(50, 100);
            var height   = random.Next(50, 100);
            var testGame = new GameModel(width, height);
            var testForm = new MaxScoreModeForm(testGame);

            Assert.AreEqual(width, testForm.ClientSize.Width);
            Assert.AreEqual(height, testForm.ClientSize.Height);
        }
예제 #3
0
        public void Should_PlayerMoveUp()
        {
            var testGame    = new GameModel(300, 300, 0, 1, 20, 20);
            var testForm    = new MaxScoreModeForm(testGame);
            var player      = testGame.Players.First();
            var playerX     = player.X;
            var playerY     = player.Y;
            var playerSpeed = player.Speed;

            player.MoveUp(testForm);

            Assert.AreEqual(playerX, player.X);
            Assert.AreEqual(playerY - playerSpeed, player.Y);
        }
예제 #4
0
        public void Should_BallMove()
        {
            var testGame     = new GameModel(300, 300, 1);
            var testForm     = new MaxScoreModeForm(testGame);
            var ballX        = testGame.Balls.First().X;
            var ballY        = testGame.Balls.First().Y;
            var ballHorSpeed = testGame.Balls.First().HorizontalSpeed;
            var ballVerSpeed = testGame.Balls.First().VerticalSpeed;

            testGame.Balls.First().Move(testForm);

            Assert.AreEqual(ballX + ballHorSpeed, testGame.Balls.First().X);
            Assert.AreEqual(ballY + ballVerSpeed, testGame.Balls.First().Y);
        }
예제 #5
0
        public void Should_StopIfGameFieldRightOrBottomEdgeReached()
        {
            var testGame    = new GameModel(300, 300, 0, 1, 290, 290);
            var testForm    = new MaxScoreModeForm(testGame);
            var player      = testGame.Players.First();
            var playerX     = player.X;
            var playerY     = player.Y;
            var playerSpeed = player.Speed;

            player.MoveDown(testForm);
            player.MoveRight(testForm);

            Assert.AreEqual(playerX, player.X);
            Assert.AreEqual(playerY, player.Y);
        }
예제 #6
0
        public void Should_StopIfGameFieldLeftOrTopEdgeReached()
        {
            var testGame    = new GameModel(300, 300);
            var testForm    = new MaxScoreModeForm(testGame);
            var player      = testGame.Players.First();
            var playerX     = player.X;
            var playerY     = player.Y;
            var playerSpeed = player.Speed;

            player.MoveUp(testForm);
            player.MoveLeft(testForm);

            Assert.AreEqual(playerX, player.X);
            Assert.AreEqual(playerY, player.Y);
        }
예제 #7
0
        public void Should_BallStayInsideGameField()
        {
            var testGame = new GameModel(200, 200, 1000);
            var testForm = new MaxScoreModeForm(testGame);

            for (int i = 0; i < 10000; i++)
            {
                testGame.Balls.ForEach(b => b.Move(testForm));
            }

            foreach (var ball in testGame.Balls)
            {
                Assert.LessOrEqual(0, ball.X);
                Assert.LessOrEqual(0, ball.Y);
                Assert.LessOrEqual(ball.X + ball.Width, testGame.FieldWidth);
                Assert.LessOrEqual(ball.Y + ball.Height, testGame.FieldHeight);
            }
        }