Beispiel #1
0
        //FUNCTGION TO START THE GAME
        private void StartGame()
        {
            isWritten = false;
            P1bat.startPosP1();                           //sets the starting position of the bat
            P2bat.startPosP2();
            ball.StartPosBall(P1bat.GetBoundary(), true); //sets starting pos of ball
            //CREATES THE BRICKS AND SETS THE COLOUR DEPENDING ON WHICH ROW THEY ARE
            bricks = new Bricks[bricksWidth, bricksHeight];

            for (int i = 0; i < bricksHeight; i++)
            {
                Color colour = Color.White;

                switch (i)
                {
                case 0:
                    colour = Color.Red;
                    break;

                case 1:
                    colour = Color.MidnightBlue;
                    break;

                case 2:
                    colour = Color.Green;
                    break;

                case 3:
                    colour = Color.Orange;
                    break;

                case 4:
                    colour = Color.Pink;
                    break;
                }
                for (int x = 0; x < bricksWidth; x++)
                {
                    bricks[x, i] = new Bricks(brickImage, new Rectangle(x * brickImage.Width, i * brickImage.Height + 300, brickImage.Width, brickImage.Height), colour);
                }
            }
        }
Beispiel #2
0
        private void StartGame()
        {
            isWritten = false;                              // sets if the written method has been done to false
            P1bat.startPosP1();                             //sets the starting position of the bat
            P2bat.startPosP2();                             // sets the starting position of the bat
            ball.StartPosBall(P1bat.GetBoundary(), true);   //sets starting pos of ball

            bricks = new Bricks[bricksWidth, bricksHeight]; //creates a new array of width and high changes colour depending on which row the bricks are in

            for (int i = 0; i < bricksHeight; i++)
            {
                Color colour = Color.White;

                switch (i)
                {
                case 0:
                    colour = Color.HotPink;
                    break;

                case 1:
                    colour = Color.Red;
                    break;

                case 2:
                    colour = Color.MidnightBlue;
                    break;

                case 3:
                    colour = Color.Orange;
                    break;

                case 4:
                    colour = Color.Green;
                    break;
                }
                for (int x = 0; x < bricksWidth; x++)
                {
                    bricks[x, i] = new Bricks(brickImage, new Rectangle(x * brickImage.Width, i * brickImage.Height + 300, brickImage.Width, brickImage.Height), colour); // creates rectangle ofr each brick created
                }
            }
        }