Example #1
0
        //Initialise Ingame Variables
        public void InitialiseGameVariables()
        {
            RocketXPos = 650;         //Set Rocket X value
            AlienDirection = -1;      //Set default direction
            AlienSpeed = 25;          //Sets a default speed (These can be changed in-game to increase difficulty)

            BossAlienDirection = -1;
            BossAlienSpeed = 100;

            //Declaring the Alien arrays:
            Invaders = new Invader[11];     //11 columns across
            InvadersOne = new Invader[11];
            InvadersTwo = new Invader[11];
            InvadersThree = new Invader[11];
            InvadersFour = new Invader[11];

            int XPos = 512;                 // Sets the default X coordinate for Aliens
            for (int Count = 0; Count < 11; Count++)    //Checks the count for amount of aliens
            {
                //First Array
                Invaders[Count] = new Invader();
                Invaders[Count].SetXPos(XPos);
                Invaders[Count].SetYPos(100);   //Each line of alien has a different Y coordinate
                //Second Array
                InvadersOne[Count] = new Invader();
                InvadersOne[Count].SetXPos(XPos);
                InvadersOne[Count].SetYPos(135);
                //Third Array
                InvadersTwo[Count] = new Invader();
                InvadersTwo[Count].SetXPos(XPos);
                InvadersTwo[Count].SetYPos(155);
                //Fourth Array
                InvadersThree[Count] = new Invader();
                InvadersThree[Count].SetXPos(XPos);
                InvadersThree[Count].SetYPos(180);
                //Fifth Array
                InvadersFour[Count] = new Invader();
                InvadersFour[Count].SetXPos(XPos);
                InvadersFour[Count].SetYPos(205);

                XPos = XPos + 32;
            }

            int BossXPos = 512;     //Sets defualt X position for Boss Alien
            BossAlien= new BossAlien();
            BossAlien.SetXPos(BossXPos);
            BossAlien.SetYPos(0);

            Ticks = 0; //Shows the amount of time passed
            Timer = 0; //Timer for each variable e.g. Alien & Boss
            Timer2 = 0;
            Timer3 = 0;
            Timer4 = 0;
            MissileFired = null;    //Missile values are set to null at start
            AlienMissileFired = null;
            AlienMissileFired2 = null;
            BossMissileFired = null;
            PlayerScore = 0;    //Player score set to 0 at start
            AmountofLives = 3; //Amount of lives the player at start of game
            BossLife = 3;     //Amount of lives Boss has at start of game
            WeaponsCount = 1; //Checks what weapon the player is using & allows switching between them
        }