Beispiel #1
0
 public CollisionClass(Bababooy booy, Bullet[] bullets, Enemy[] enemys, Powerup[] powerups)
 {
     myBababooy = booy;
     myBullets  = bullets;
     myPowerups = powerups;
     myEnemy    = enemys;
     myRand     = new Random();
     myMaxSpeed = 4;
 }
Beispiel #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            SetUpXNADevice();

            myIsMainMenuUp    = true;
            myIsControlMenuUp = false;


            playerOne             = new Bababooy(graphics, Content);
            myEnemyArray          = new Enemy[80];
            myPowerups            = new Powerup[4];
            myIsPaused            = false;
            myMenuItemArray       = new MenuItem[2];
            myControlItemArray    = new MenuItem[1];
            myControlItemArray[0] = new MenuItem(graphics, Content, "playbutton", new Rectangle(450, 200, 200, 50));
            myMenuItemArray[0]    = new MenuItem(graphics, Content, "playbutton", new Rectangle(50, 200, 200, 50));
            myMenuItemArray[1]    = new MenuItem(graphics, Content, "controlsbutton", new Rectangle(50, 300, 200, 50));

            myMainMenu    = new Menu(graphics, Content, "splash", new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), myMenuItemArray);
            myControlMenu = new Menu(graphics, Content, "controls", new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), myControlItemArray);


            myScoreFont    = Content.Load <SpriteFont>("TimesNewRoman");
            myScoreBatch   = new SpriteBatch(graphics.GraphicsDevice);
            myPowerUpBatch = new SpriteBatch(graphics.GraphicsDevice);
            myScorePos     = new Vector2(550, 10);
            rand           = new Random();

            backgroundBatch = new SpriteBatch(graphics.GraphicsDevice);
            myKeyState      = Keyboard.GetState();
            myPrevKeyState  = myKeyState;

            for (int i = 0; i < myEnemyArray.Length; i++)
            {
                if (rand.Next(0, 5) == 1)
                {
                    myEnemyArray[i] = new Enemy(graphics, Content, rand.Next(300, 16000), rand.Next(100, 500), rand.Next(1, 4), "terrorest4", 400);
                }
                else if (rand.Next(0, 4) == 1)
                {
                    myEnemyArray[i] = new Enemy(graphics, Content, rand.Next(300, 16000), rand.Next(100, 500), rand.Next(1, 4), "terrorest3", 300);
                }
                else if (rand.Next(0, 3) == 1)
                {
                    myEnemyArray[i] = new Enemy(graphics, Content, rand.Next(300, 16000), rand.Next(100, 500), rand.Next(1, 4), "terrorest2", 200);
                }
                else
                {
                    myEnemyArray[i] = new Enemy(graphics, Content, rand.Next(300, 16000), rand.Next(100, 500), rand.Next(1, 4));
                }
            }

            myPowerups[0] = new Powerup(Content.Load <Texture2D>("shotgun"), "Shotgun");
            myPowerups[1] = new Powerup(Content.Load <Texture2D>("shotgun"), "Shotgun");
            myPowerups[2] = new Powerup(Content.Load <Texture2D>("Flack"), "Flack");
            myPowerups[3] = new Powerup(Content.Load <Texture2D>("Flack"), "Flack");

            for (int i = 0; i < myPowerups.Length; i++)
            {
                myPowerups[i].X = rand.Next(700, 16000);
                myPowerups[i].Y = rand.Next(100, 500);
            }

            collisionClass = new CollisionClass(playerOne, playerOne.getBullets(), myEnemyArray, myPowerups);

            base.Initialize();
        }