Ejemplo n.º 1
0
        void checkIfIAmShot()
        {
            Rectangle r    = shooter.getBoundingBoxAA();
            int       temp = targets.collisionWithRect(r);

            if (temp == -1)
            {
                return;
            }
            Sprite3 s = targets.getSprite(temp);

            makeExplosion(shooter.getPos());
            makeExplosion(s.getPos());
            adjustScore(scoreIfPlayerHit, s.getPosX(), s.getPosY());
            s.active  = false;
            s.visible = false;
            //shooter.visible = false;
            lives   = lives - 1;
            mgState = 2;
            timeIn2 = 0;
            if (lives <= 0)
            {
                mgState = 4;
            }
        }
Ejemplo n.º 2
0
        public void NewBall(float x, float y)
        {
            Sprite3 ball = new Sprite3(true, texBall, x, y);

            ball.setBBandHSFractionOfTexCentered(0.4f);

            ball.setPos(paddle.getPos() + ballOffset);
            ball.setDeltaSpeed(new Vector2(7, 0));

            ballList.addSpriteReuse(ball);
        }
Ejemplo n.º 3
0
 void moveBullets()
 {
     for (int i = 0; i < shotsMax; i++)
     {
         if (bullets[i].X != 0)
         {
             //bullets[i].X = shooter.getPosX() + shooterShellOffset.X;
             bullets[i].Y = bullets[i].Y - bulletSpeed;
             if (bullets[i].Y < innerRectangle.Y - shotLength)
             {
                 bullets[i].X = 0;
             }
         }
         if (bullets[i].X != 0)
         {
             // check for collision
             int tt = targets.pointInList(bullets[i]);
             if (tt == -1)
             {
                 tt = targets.pointInList(bullets[i] + new Vector2(0, shotLength));
             }
             if (tt != -1)
             {
                 Sprite3 s = targets.getSprite(tt);
                 makeExplosion(s.getPos());
                 s.visible = false;
                 s.active  = false;
                 adjustScore(scoreIfTargetHit, s.getPosX(), s.getPosY());
                 if (!shootThrough)
                 {
                     bullets[i].X = 0;              // remove bullet
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
        public override void Update(GameTime gameTime)
        {
            ticks++;

            //load animation
            //anmiation1.animationTick();
            dragonList.animationTick();
            if (scrolling1.rectangle.X + scrolling1.texture.Width <= 0)
            {
                scrolling1.rectangle.X = scrolling2.rectangle.X + scrolling2.texture.Width;
            }
            if (scrolling2.rectangle.X + scrolling2.texture.Width <= 0)
            {
                scrolling2.rectangle.X = scrolling1.rectangle.X + scrolling1.texture.Width;
            }

            scrolling1.Update();
            scrolling2.Update();

            for (int i = 0; i < dragonList.count(); i++)
            {
                Sprite3 s = dragonList.getSprite(i);
                if (s == null)
                {
                    continue;
                }
                if (!s.active)
                {
                    continue;
                }
                if (!s.visible)
                {
                    continue;
                }
                if (ball.getBoundingBoxAA().Intersects(s.getBoundingBoxAA()))
                {
                    baz.Play();
                    s.setActive(false);
                    scoure++;
                    ball.setDeltaSpeed(ball.getDeltaSpeed() * new Vector2(1, -1));
                    setSys5();
                    p.Update(gameTime);
                }
            }

            if (k.IsKeyDown(Keys.B) && prevK.IsKeyUp(Keys.B)) // ***
            {
                showbb = !showbb;
            }
            k = Keyboard.GetState();

            if (k.IsKeyDown(Keys.Right))
            {
                if (paddle.getPosX() < rhs - texpaddle.Width)
                {
                    paddle.setPosX(paddle.getPosX() + paddleSpeed);
                }
            }

            if (k.IsKeyDown(Keys.Left))
            {
                if (paddle.getPosX() > lhs)
                {
                    paddle.setPosX(paddle.getPosX() - paddleSpeed);
                }
            }

            if (ballStuck)
            {
                ball.setPos(paddle.getPos() + ballOffset);
            }

            //if (ballStuck)
            //{
            //    ball.setPos(paddle.getPos() + ballOffset);
            //    if (k.IsKeyDown(Keys.Space) && prevK.IsKeyUp(Keys.Space))
            //    {
            //        ballStuck = false;
            //        ball.setDeltaSpeed(new Vector2(1, -3));
            //    }
            //}
            else
            {
                // move ball
                ball.savePosition();
                ball.moveByDeltaXY();
            }

            if (ballStuck)
            {
                ball.setPos(paddle.getPos() + ballOffset);
                if (k.IsKeyDown(Keys.Space) && prevK.IsKeyUp(Keys.Space))
                {
                    ballStuck = false;
                    ball.setDeltaSpeed(new Vector2(2, -3));
                }
            }
            else
            {
                // move ball
                ball.savePosition();
                ball.moveByDeltaXY();
                Rectangle ballbb = ball.getBoundingBoxAA();

                if (ballbb.X + ballbb.Width > rhs)
                {
                    ball.setDeltaSpeed(ball.getDeltaSpeed() * new Vector2(-1, 1));
                }

                if (ballbb.X < lhs)
                {
                    ball.setDeltaSpeed(ball.getDeltaSpeed() * new Vector2(-1, 1));
                }

                if (ballbb.Y < top)
                {
                    ball.setDeltaSpeed(ball.getDeltaSpeed() * new Vector2(1, -1));
                }

                //pedal intersects

                if (ballbb.Intersects(paddle.getBoundingBoxAA()))

                {
                    ball.setDeltaSpeed(ball.getDeltaSpeed() * new Vector2(1, -1));
                }
            }
            if (k.IsKeyDown(Keys.P))
            {
                gameStateManager.setLevel(0);
            }
            if (k.IsKeyDown(Keys.M))
            {
                gameStateManager.setLevel(0);
                ball.setPos(xx, yy);
                paddle.setPos(xx, bot - texpaddle.Height);
                scoure = 0;
                //ball.setDeltaSpeed(new Vector2(0,0));
                for (int i = 0; i < dragonList.count(); i++)
                {
                    Sprite3 s = dragonList.getSprite(i);
                    s.setActive(true);
                }
            }


            if (ball.getPosY() > bot)
            {
                gameStateManager.setLevel(5);
                ball.setPos(xx, yy);
                paddle.setPos(xx, bot - texpaddle.Height);
                scoure = 0;
                //ball.setDeltaSpeed(new Vector2(0,0));
                for (int i = 0; i < dragonList.count(); i++)
                {
                    Sprite3 s = dragonList.getSprite(i);
                    s.setActive(true);
                    // p.Update(gameTime);
                }
            }
            // next leve condition
            if (scoure >= 15)
            {
                gameStateManager.setLevel(0);
                limSound.playSound();
            }
            ballPos = new Vector2(ball.getPosX(), ball.getPosY());
            if (p != null)
            {
                p.Update(gameTime);
            }
            base.Update(gameTime);
        }
Ejemplo n.º 5
0
 public Vector2 getPos()
 {
     return(button.getPos());
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        /// This is a mess, please forgive me
        protected override void Update(GameTime gameTime)
        {
            //Console.WriteLine(enemies.count());
            curPos = horse.getPos();
            bool keyDown = false;

            switch (level)
            {
            case 1:
                horse.setWidthHeight(1568 / 8 * 0.3f, texHorseRun.Height * 0.3f);
                k = Keyboard.GetState();
                if (!started)
                {
                    started = true;
                    StartMovement(8);
                }

                if (k.IsKeyDown(Keys.Down))
                {
                    keyDown = true;
                    horse.setPosY(horse.getPosY() + movementSpeed - 2);
                }

                if (k.IsKeyDown(Keys.Up))
                {
                    keyDown = true;
                    horse.setPosY(horse.getPosY() - movementSpeed + 2);
                }

                if (k.IsKeyDown(Keys.Left))
                {
                    keyDown = true;
                    horse.setFlip(SpriteEffects.FlipHorizontally);
                    horse.setPosX(horse.getPosX() - movementSpeed + 2);
                }

                if (k.IsKeyDown(Keys.Right))
                {
                    keyDown = true;
                    horse.setFlip(SpriteEffects.None);
                    horse.setPosX(horse.getPosX() + movementSpeed - 2);
                }
                if (!keyDown)
                {
                    horse.setAnimationSequence(anim, 0, 7, 0);
                }
                else
                {
                    horse.setAnimationSequence(anim, 0, 7, 8);
                }
                //387 330
                if (curPos.X >= -155 && curPos.X <= -75 && curPos.Y >= 330 && curPos.Y <= 387)
                {
                    horse.setPos(xx, yy);
                    started = false;
                    horse.setFlip(SpriteEffects.None);
                    level = 0;
                }

                horseRun.animationTick(gameTime);
                mainCamera.Follow(horse);

                break;

            default:
                if (!started)
                {
                    if (k.IsKeyDown(Keys.D1) || k.IsKeyDown(Keys.NumPad1))
                    {
                        difficulty = 1;
                    }
                    else if (k.IsKeyDown(Keys.D2) || k.IsKeyDown(Keys.NumPad2))
                    {
                        difficulty = 2;
                    }
                    else if (k.IsKeyDown(Keys.D3) || k.IsKeyDown(Keys.NumPad3))
                    {
                        difficulty = 3;
                    }
                }
                switch (difficulty)
                {
                case 1:
                    difficultyOffset = 1;
                    break;

                case 2:
                    difficultyOffset = 0.5f;
                    break;

                case 3:
                    difficultyOffset = 0.1f;
                    break;

                default:
                    break;
                }
                horse.setWidthHeight(1568 / 8 * 0.5f, texHorseRun.Height * 0.5f);
                //This timer makes basic instructions disappear after 3 seconds
                if (textFadeTimer < 3 && started)
                {
                    textFadeTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
                }
                if (started)
                {
                    enemySpawnTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
                }

                if (enemySpawnTimer > difficultyOffset)
                {
                    enemySpawnTimer = 0;
                    LoadEnemies();
                }

                //Escape key exits game
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                {
                    Exit();
                }

                //Keyboard current and previous state
                prevK = k;
                k     = Keyboard.GetState();

                //Begin all game functionality essentially
                if (k.IsKeyDown(Keys.Enter) && !started)
                {
                    started = true;
                    StartMovement(8);
                }

                if (started)
                {
                    //Bounding box activation key
                    if (k.IsKeyDown(Keys.B) && prevK.IsKeyUp(Keys.B))
                    {
                        showbb = !showbb;
                    }

                    //Game over is a bool that is used to ensure the player can't move horse after it is dead, causes errors otherwise
                    if (!gameOver)
                    {
                        //Player movement down
                        if (k.IsKeyDown(Keys.Down))
                        {
                            if (horseRun.getSprite(0).getPosY() < bot - horse.getHeight())
                            {
                                horseRun.getSprite(0).setPosY(horseRun.getSprite(0).getPosY() + movementSpeed);
                            }
                        }
                        //Player movement up
                        if (k.IsKeyDown(Keys.Up))
                        {
                            if (horseRun.getSprite(0).getPosY() > top)
                            {
                                horseRun.getSprite(0).setPosY(horseRun.getSprite(0).getPosY() - movementSpeed);
                            }
                        }
                    }

                    for (int e = 0; e < enemies.count(); e++)
                    {
                        if (enemies[e].getVisible())
                        {
                            enemies[e].setPosX(enemies[e].getPosX() - enemyMovementSpeed);
                        }
                        if (enemies[e].getPosX() < 0 - texEnemy.Width)
                        {
                            enemies[e].setVisible(false);
                        }
                    }

                    //Collision detection, arrow to enemy
                    for (int ea = 0; ea < quiver.count(); ea++)
                    {
                        int ac = enemies.collisionWithRect(quiver[ea].getBoundingBoxAA());
                        if (ac != -1)
                        {
                            score++;
                            Blood(enemies.getSprite(ac).getPosX(), enemies.getSprite(ac).getPosY(), false);
                            enemies.getSprite(ac).setVisible(false);
                            quiver[ea].setVisible(false);
                            quiver[ea].setPos(new Vector2(0, 0));
                            //LoadEnemies();
                        }
                    }


                    //Allow player to increase or decrease speed
                    if (Keyboard.GetState().IsKeyDown(Keys.Right))
                    {
                        enemyMovementSpeed = fastEnemy;
                        horse.setAnimationSequence(anim, 0, 7, fastPlayer);
                    }
                    else if (Keyboard.GetState().IsKeyDown(Keys.Left))
                    {
                        enemyMovementSpeed = slowEnemy;
                        horse.setAnimationSequence(anim, 0, 7, slowPlayer);
                    }
                    else if (started)
                    {
                        enemyMovementSpeed = normalEnemy;
                        horse.setAnimationSequence(anim, 0, 7, normalPlayer);
                    }

                    //Scrolling background functionality
                    if (scrolling1.rectangle.X + scrolling1.texture.Width <= 0)
                    {
                        scrolling1.rectangle.X = scrolling2.rectangle.X + scrolling2.texture.Width;
                    }
                    if (scrolling2.rectangle.X + scrolling2.texture.Width <= 0)
                    {
                        scrolling2.rectangle.X = scrolling1.rectangle.X + scrolling1.texture.Width;
                    }
                    scrolling1.Update();
                    scrolling2.Update();

                    //Game over is a bool that is used to ensure the player can't move horse after it is dead, causes errors otherwise
                    if (!gameOver)
                    {
                        //Collision detection, enemy to player
                        int rc = enemies.collisionWithRect(horse.getBoundingBoxAA());
                        if (rc != -1)
                        {
                            Blood(horse.getPosX(), horse.getPosY(), true);
                            movementSpeed      = 0;
                            enemyMovementSpeed = 0;
                            scrolling1.speed   = 0;
                            scrolling2.speed   = 0;
                            for (int i = 0; i < horseRun.count(); i++)
                            {
                                horseRun.deleteSprite(i);
                            }
                            gameOver = true;
                        }
                    }

                    //Shooting arrow functionality
                    if (Keyboard.GetState().IsKeyDown(Keys.Space) && !arrowShot)
                    {
                        Arrow();
                        arrowShot = true;
                    }
                    for (int a = 0; a < quiver.count(); a++)
                    {
                        if (quiver[a].getVisible())
                        {
                            quiver[a].savePosition();
                            quiver[a].moveByDeltaXY();
                        }
                        if (quiver[a].getPosX() > 800)
                        {
                            quiver[a].setVisible(false);
                        }
                    }
                    if (arrowShot)
                    {
                        arrowTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
                    }
                    if (arrowTimer > 0.5f)
                    {
                        arrowTimer = 0;
                        arrowShot  = false;
                    }
                }

                //Animation ticks for anything that is being animated
                horseRun.animationTick(gameTime);
                enemies.animationTick(gameTime);
                bloodSplat.animationTick(gameTime);

                if (gameOver)
                {
                    deathTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
                }
                break;
            }
            base.Update(gameTime);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            prevK = k;
            k     = Keyboard.GetState();

            if (k.IsKeyDown(Keys.B) && prevK.IsKeyUp(Keys.B)) // ***
            {
                showbb = !showbb;
            }

            if (k.IsKeyDown(Keys.Right))
            {
                if (paddle.getPosX() < rhs - texpaddle.Width)
                {
                    paddle.setPosX(paddle.getPosX() + paddleSpeed);
                }
            }

            if (k.IsKeyDown(Keys.Left))
            {
                if (paddle.getPosX() > lhs)
                {
                    paddle.setPosX(paddle.getPosX() - paddleSpeed);
                }
            }
            if (ballStuck)
            {
                ball.setPos(paddle.getPos() + ballOffset);
                if (k.IsKeyDown(Keys.Space) && prevK.IsKeyUp(Keys.Space))
                {
                    ballStuck = false;
                    ball.setDeltaSpeed(new Vector2(2, -3));
                }
            }

            else
            {
                // move ball
                ball.savePosition();
                ball.moveByDeltaXY();
                Rectangle ballbb = ball.getBoundingBoxAA();

                if (ballbb.X + ballbb.Width > rhs)
                {
                    ball.setDeltaSpeed(ball.getDeltaSpeed() * new Vector2(-1, 1));
                }

                if (ballbb.X < lhs)
                {
                    ball.setDeltaSpeed(ball.getDeltaSpeed() * new Vector2(-1, 1));
                }

                if (ballbb.Y < top)
                {
                    ball.setDeltaSpeed(ball.getDeltaSpeed() * new Vector2(1, -1));
                }

                if (ballbb.Intersects(paddle.getBoundingBoxAA()))
                {
                    ball.setDeltaSpeed(ball.getDeltaSpeed() * new Vector2(1, -1));
                }
            }



            // TODO: Add your update logic here

            base.Update(gameTime);
        }
Ejemplo n.º 8
0
        public override void Update(GameTime gameTime)
        {
            prevKeyState     = keyState;
            keyState         = Keyboard.GetState();
            timer           += 1;
            explostionTimer += 1;
            explosionAnimation.animationTick(gameTime);
            mineExplostionAnimation.animationTick(gameTime);
            missileSmoke.Update(gameTime);
            exLimSound.Update(gameTime);

            previousMouseState = currentMouseState;
            currentMouseState  = Mouse.GetState();

            mouse_x = currentMouseState.X;
            mouse_y = currentMouseState.Y;

            // Sets up mine
            if (currentMouseState.LeftButton == ButtonState.Pressed)
            {
                minePos.X   = mouse_x;
                minePos.Y   = mouse_y;
                drawMines   = true;
                mine.active = true;
                mineCount   = 1;
            }

            // Controls player movements
            if (keyState.IsKeyDown(Keys.Left))
            {
                if (player.getPosX() > Dir.leftBoundary)
                {
                    player.setPosX(player.getPosX() - 4);                   // Moves player 3 units left
                    player.setFlip(SpriteEffects.FlipHorizontally);
                }
            }
            if (keyState.IsKeyDown(Keys.Right))
            {
                if (player.getPosX() < (Dir.rightBoundary - (player.getWidth() - 5)))
                {
                    player.setPosX(player.getPosX() + 4);                   // Moves player 3 units right
                    player.setFlip(SpriteEffects.None);
                }
            }

            // Moves enemy sprite
            enemy1.setPosX(enemy1.getPosX() + Dir.rnd.Next(1, 3));
            enemy2.setPosX(enemy2.getPosX() - Dir.rnd.Next(1, 3));

            // If enemy runs off screen, reset position to random x postion
            if (enemy1.getPosX() > Dir.rightBoundary + 60)
            {
                enemy1.setPos(Dir.rnd.Next(-400, -250), Dir.rnd.Next(200, 700));
            }
            if (enemy2.getPosX() < Dir.leftBoundary - (enemy2.getWidth() + 50))
            {
                enemy2.setPos(Dir.rnd.Next(Dir.rightBoundary, Dir.rightBoundary + 200), Dir.rnd.Next(200, 700));
            }

            // Shoot missile
            if (keyState.IsKeyDown(Keys.Space) && prevKeyState.IsKeyUp(Keys.Space))
            {
                missile.setPos(player.getPosX() + player.getWidth() / 2, player.getPosY() - missile.getHeight());
                missile.active = true;
                drawSmoke();
                drawMissile = true;
                if (missileCount > 0)
                {
                    missileCount--;
                }
            }

            if (missileCount == 0)
            {
                missileCount = 5;
            }

            if (missile.getPosY() < 185 + missile.getHeight())
            {
                missile.setPos(player.getPos());
                drawMissile = false;
                missileSmoke.deActivate();
            }

            if (timer % 361 == 360)
            {
                anchor.setPos(enemy1.getPosX() + enemy1.getWidth() / 2, enemy1.getPosY() + enemy1.getHeight() / 2);
                anchorDraw = true;
            }

            if (anchor.getPosY() > Dir.bottomBoundary + anchor.getHeight())
            {
                anchor.active = false;
                anchorDraw    = false;
            }
            // Collision Control
            enemy1Collision = missile.collision(enemy1);
            enemy2Collision = missile.collision(enemy2);

            if (enemy1Collision)
            {
                enemy1.hitPoints = enemy1.hitPoints - 10;
                currXMissile     = enemy1.getPosX() + enemy1.getWidth() / 2;
                currYMissile     = enemy1.getPosY() - enemy1.getHeight() / 2;
                if (enemy1.hitPoints <= 0)
                {
                    collision1       = true;
                    enemy1.hitPoints = 10;
                    Dir.enemy1Count++;
                    missileSmoke.deActivate();
                }
                getSetMissile();
            }
            if (enemy2Collision)
            {
                missileSmoke.deActivate();
                enemy2.hitPoints = enemy2.hitPoints - 10;
                drawMissile      = false;
                if (enemy2.hitPoints <= 0)
                {
                    currXMissile = enemy2.getPosX() + enemy2.getWidth() / 2;
                    currYMissile = enemy2.getPosY() - enemy2.getHeight() / 2;
                    collision2   = true;
                    Dir.enemy2Count++;
                    enemy2.hitPoints = 20;
                }
                getSetMissile();
            }

            // Gain 10 hp if missile hits the anchor preserve
            bool lifeGain = missile.collision(life);

            if (lifeGain == true)
            {
                if (player.hitPoints < 50)
                {
                    player.hitPoints = player.hitPoints + 10;
                }
                lifeGain    = false;
                drawMissile = false;
                life.active = false;
                life.setPos(new Vector2(Dir.rnd.Next(250, 800), Dir.rnd.Next(400, 600)));
                missile.active = false;
                missile.setPos(player.getPosX(), player.getPosY());
                missileSmoke.deActivate();
            }

            bool anchorCollision = anchor.collision(player);

            if (anchorCollision)
            {
                anchorDraw = false;
                anchor.setActiveAndVisible(false);
                anchor.setPos(new Vector2(-100, -100));
                player.hitPoints = player.hitPoints - 20;
            }

            mineCollission = mine.collision(enemy1);
            if (mineCollission)
            {
                mine.active = false;
                drawMines   = false;
                mineCurrPos = mine.getPos();
                mine.setPos(new Vector2(-100, 0));
                enemy1.setPos(Dir.rnd.Next(-400, -250), Dir.rnd.Next(200, 700));
                mineCollisionToggle = true;
                score           += 150;
                mineCount        = 0;
                Dir.enemy1Count += 1;
                exLimSound.playSoundIfOk();
            }

            mineCollission2 = mine.collision(enemy2);
            if (mineCollission2)
            {
                mine.active = false;
                drawMines   = false;
                mineCurrPos = mine.getPos();
                mine.setPos(new Vector2(-100, 0));
                enemy2.setPos(Dir.rnd.Next(-400, -250), Dir.rnd.Next(200, 700));
                mineCollisionToggle2 = true;
                score           += 200;
                mineCount        = 0;
                Dir.enemy2Count += 1;
                exLimSound.playSoundIfOk();
            }
            // Toggle BB
            if (keyState.IsKeyDown(Keys.B) && prevKeyState.IsKeyUp(Keys.B))
            {
                showBB = !showBB;
            }

            // Pause
            if (keyState.IsKeyDown(Keys.P) && !prevKeyState.IsKeyDown(Keys.P))
            {
                gameStateManager.pushLevel(3);
            }

            // Help State
            if (keyState.IsKeyDown(Keys.F1) && !prevKeyState.IsKeyDown(Keys.F1))
            {
                gameStateManager.pushLevel(5);
            }

            if (player.hitPoints < 0)
            {
                player.hitPoints = 0;
            }

            // End State
            if (score >= 1000 || player.hitPoints <= 0)
            {
                if (timer % 181 == 180)
                {
                    gameStateManager.setLevel(4);
                }
            }
        }
Ejemplo n.º 9
0
        public override void Update(GameTime gameTime)
        {
            prevKeyState = keyState;
            keyState     = Keyboard.GetState();
            timer       += 1;
            explosionAnimation.animationTick(gameTime);
            missileSmoke.Update(gameTime);

            if (keyState.IsKeyDown(Keys.Left))
            {
                if (player.getPosX() > Dir.leftBoundary)
                {
                    player.setPosX(player.getPosX() - 4);                   // Moves player 4 units left
                    player.setFlip(SpriteEffects.FlipHorizontally);
                }
            }
            if (keyState.IsKeyDown(Keys.Right))
            {
                if (player.getPosX() < (Dir.rightBoundary - (player.getWidth() - 5)))
                {
                    player.setPosX(player.getPosX() + 4);                   // Moves player 4 units right
                    player.setFlip(SpriteEffects.None);
                }
            }
            enemy1.setPosX(enemy1.getPosX() + Dir.rnd.Next(1, 3));
            enemy2.setPosX(enemy2.getPosX() - Dir.rnd.Next(1, 3));
            enemy3.setPosX(enemy3.getPosX() + Dir.rnd.Next(2, 4));

            // If enemy runs off screen, reset position to random x postion
            if (enemy1.getPosX() > Dir.rightBoundary + 60)
            {
                enemy1.setPos(Dir.rnd.Next(-400, -250), Dir.rnd.Next(200, 700));
            }
            if (enemy2.getPosX() < Dir.leftBoundary - (enemy2.getWidth() + 50))
            {
                enemy2.setPos(Dir.rnd.Next(Dir.rightBoundary, Dir.rightBoundary + 200), Dir.rnd.Next(200, 700));
            }
            if (enemy3.getPosX() > Dir.rightBoundary + 60)
            {
                enemy3.setPos(Dir.rnd.Next(-400, -250), Dir.rnd.Next(200, 700));
            }

            if (keyState.IsKeyDown(Keys.Space) && prevKeyState.IsKeyUp(Keys.Space))
            {
                missile.setPos(player.getPosX() + player.getWidth() / 2, player.getPosY() - missile.getHeight());
                missile.active = true;
                drawMissile    = true;
                drawSmoke();
                if (missileCount > 0)
                {
                    missileCount--;
                }
            }

            if (missileCount == 0)
            {
                missileCount = 5;
            }

            if (missile.getPosY() < 185 + missile.getHeight())
            {
                missile.setPos(player.getPos());
                drawMissile = false;
                missileSmoke.deActivate();
            }

            enemy1Collision = missile.collision(enemy1);
            enemy2Collision = missile.collision(enemy2);
            enemy3Collision = missile.collision(enemy3);

            explostionTimer += 1;
            if (enemy1Collision)
            {
                enemy1.hitPoints = enemy1.hitPoints - 10;
                currXMissile     = enemy1.getPosX() + enemy1.getWidth() / 2;
                currYMissile     = enemy1.getPosY() - enemy1.getHeight() / 2;
                if (enemy1.hitPoints <= 0)
                {
                    collision1 = true;
                    Dir.enemy1Count++;
                    enemy1.hitPoints = 10;
                }
                getSetMissile();
            }
            if (enemy2Collision)
            {
                missileSmoke.deActivate();
                enemy2.hitPoints = enemy2.hitPoints - 10;
                drawMissile      = false;
                if (enemy2.hitPoints <= 0)
                {
                    currXMissile = enemy2.getPosX() + enemy2.getWidth() / 2;
                    currYMissile = enemy2.getPosY() - enemy2.getHeight() / 2;
                    collision2   = true;
                    Dir.enemy2Count++;
                    enemy2.hitPoints = 20;
                }
                getSetMissile();
            }
            if (enemy3Collision)
            {
                enemy3.hitPoints = enemy3.hitPoints - 10;
                currXMissile     = enemy3.getPosX() + enemy3.getWidth() / 2;
                currYMissile     = enemy3.getPosY() - enemy3.getHeight() / 2;
                if (enemy3.hitPoints <= 0)
                {
                    collision3 = true;
                    Dir.enemy3Count++;
                    enemy3.hitPoints = 10;
                }
                getSetMissile();
            }

            // Toggle showing Boundary Box
            if (keyState.IsKeyDown(Keys.B) && prevKeyState.IsKeyUp(Keys.B))
            {
                showBoundary = !showBoundary;
            }

            if (keyState.IsKeyDown(Keys.P) && !prevKeyState.IsKeyDown(Keys.P))
            {
                gameStateManager.pushLevel(3);
            }

            if (keyState.IsKeyDown(Keys.F1) && !prevKeyState.IsKeyDown(Keys.F1))
            {
                gameStateManager.pushLevel(5);
            }

            if (score >= 300)
            {
                if (timer % 181 == 180)
                {
                    gameStateManager.setLevel(2);
                }
            }
            exLimSound.Update(gameTime);
        }