void missile()
 {
     for (int i = 1; i < missileBulletPowerUpCounter + 1; i++)
     {
         game.playerBullets.Add(new MissileBullet(x, y, MyRandom.Range(0, 360) * MyMath.Deg2Rad, game));
     }
 }
Exemple #2
0
 public override void Update()
 {
     if (count == 180)
     {
         x = MyRandom.Range(0, Screen.Width);
         y = MyRandom.Range(0, Screen.Height);
         for (int i = 0; i < 360; i += 10)
         {
             game.enemyBullets.Add(new EnemyBullet(x, y, i * MyMath.Deg2Rad, 8f));
         }
         count = 0;
     }
     if (count == 30)
     {
         for (int i = 0; i < 360; i += 10)
         {
             game.enemyBullets.Add(new EnemyBullet(x, y, i * MyMath.Deg2Rad, 6f));
         }
     }
     if (count == 60)
     {
         for (int i = 0; i < 360; i += 10)
         {
             game.enemyBullets.Add(new EnemyBullet(x, y, i * MyMath.Deg2Rad, 4f));
         }
     }
     count++;
 }
Exemple #3
0
 public Zako2(Game game, float x, float y, float count)
     : base(game, x, y)
 {
     vx   = ((float)Math.Cos(MyRandom.Range(90, 270) * MyMath.Deg2Rad)) * Speed;
     vy   = ((float)Math.Sin(MyRandom.Range(90, 270) * MyMath.Deg2Rad)) * Speed;
     life = 10;
 }
Exemple #4
0
        public override void Update()
        {
            x += vx;
            y += vy;

            if (y < 0 || y > Screen.Height)
            {
                vy = -vy;
            }

            game.enemyBullets.Add(new EnemyBullet(x, y, MyRandom.Range(0, 360) * MyMath.Deg2Rad, 8f));
        }
Exemple #5
0
 public Boss2(Game game, float x, float y, Wave wave, int HPMultiplier) : base(game, x, y)
 {
     life = 1500 * HPMultiplier;
     this.HPMultiplier = HPMultiplier;
     collisionRadius   = 70;
     angle             = MyMath.PointToPointAngle(x, y, CenterPointX, CenterPointY);
     for (int i = 0; i < 4; i++) //adds the four turrents to the boss
     {
         float turrentposition = 90 * i * MyMath.Deg2Rad;
         turrents.Add(new Turrent(game, x, y, turrentposition, this, MyRandom.Range(0, 4), HPMultiplier));
         turrentCount = i;
     }
     this.wave = wave;
 }
Exemple #6
0
        public override void Update()
        {
            if (state == State.Appear)
            {
                x += (float)Math.Cos(angle) * 5;
                y += (float)Math.Sin(angle) * 5;
                foreach (Turrent turrent in turrents)
                {
                    turrent.Update();
                }

                if (Math.Abs(MyMath.DistanceBetweenTwoPoints(x, y, CenterPointX, CenterPointY)) < Screen.Width / 2 - Size)
                {//once the boss reaches a certain portion of the screen move into the main phase
                    state = State.Normal;
                }
            }
            else if (state == State.Normal)
            {
                angleToPlayer = MyMath.PointToPointAngle(x, y, game.player.x, game.player.y);

                foreach (Turrent turrent in turrents)
                {
                    turrent.Update();
                }
                TurrentCollisionWithPlayerBullet(); //these are needed because these lists are in this class as opposed to the game class
                PointsForBlowingUpTurrent();        //award 50 points for blowing up a turrent
                turrents.RemoveAll(t => t.isDead);  //remove dead turrents

                if (turrents.Count < turrentCount + 1)
                {
                    turrentCount--;
                    mad = true;
                }
                if (mad == true)
                {
                    madCount++;
                    angle += 4 * angleV; //move faster
                    if (madCount == 180)
                    {
                        angleV   = -angleV; //reverse direction after "mad" phase
                        madCount = 0;
                        mad      = false;
                    }
                }
                else
                {
                    angle += angleV;  //default movement speed
                }
                x = (float)Math.Cos(angle) * -MyMath.DistanceBetweenTwoPoints(CenterPointX, CenterPointY, x, y) + Screen.Width / 2;
                y = (float)Math.Sin(angle) * -MyMath.DistanceBetweenTwoPoints(CenterPointX, CenterPointY, x, y) + Screen.Height / 2;

                if (turrents.Count == 0)
                {
                    state = State.Swoon;                      //once turrents are destroyed go into swoon state
                }
            }
            else if (state == State.Swoon)
            {//state bofore 2nd phase
                swoonTime--;

                if (swoonTime <= 0)
                {
                    state = State.Angry;
                }
            }
            else if (state == State.Angry)
            {//2nd phase
                angleToPlayer = MyMath.PointToPointAngle(x, y, game.player.x, game.player.y);

                if (specialAbilityCount == 0)
                {
                    for (int i = 0; i < 360; i += 20)
                    {
                        game.enemyBullets.Add(new EnemyBullet(x, y, i * MyMath.Deg2Rad, 8f));
                    }
                    for (int i = 10; i < 360; i += 20)
                    {
                        game.enemyBullets.Add(new EnemyBullet(x, y, i * MyMath.Deg2Rad, 4f));
                    }
                }
                if (specialAbilityCount > 100)
                {
                    if (specialAbilityCount % 2 == 0)
                    {
                        x = x + specialAbilityCount - 100;
                    }
                    if (specialAbilityCount % 2 == 1)
                    {
                        x = x - specialAbilityCount + 100;
                    }
                }

                if (specialAbilityCount == 200)
                {
                    specialAbilityCount = 0;
                    state = State.Invincible;
                }
                specialAbilityCount++;
            }
            else if (state == State.Invincible)
            {//this is when the boss teleports away - can't be hit in this state
                specialAbilityCount++;

                if (specialAbilityCount < 50)
                {
                    x = game.player.x;
                    y = game.player.y;
                }
                if (specialAbilityCount == 100)
                {
                    specialAbilityCount = 0;
                    state = State.Angry;
                }
            }
            else if (state == State.Dying)
            {//Death animation
                dyingTime--;
                y             += .2f;
                angleToPlayer += .2f * MyMath.Deg2Rad;
                x              = MyRandom.Range(x - 2f, x + 2f);

                if (dyingTime % 4 == 0)
                {
                    game.explosions.Add(new Explosion(
                                            MyRandom.Range(x - Size / 2, x + Size / 2),
                                            MyRandom.Range(y - Size / 2, y + Size / 2)));
                }

                if (dyingTime <= 0)
                {
                    isDead = true;
                    for (int i = 0; i < 25; i++)
                    {
                        game.explosions.Add(new Explosion(
                                                MyRandom.Range(x - Size / 2, x + Size / 2),
                                                MyRandom.Range(y - Size / 2, y + Size / 2)));
                    }
                }
            }
        }
Exemple #7
0
        public override void Update()
        {
            angle += angleV; //change angle every frame
            //circle boss with a distance of 50
            x = (float)Math.Cos(angle) * 50 + boss.x;
            y = (float)Math.Sin(angle) * 50 + boss.y;

            angleToPlayer = MyMath.PointToPointAngle(x, y, game.player.x, game.player.y);

            if (gunID == 0)
            {//shoots at player every 50 frames within an error of 15 degrees
                count++;
                if (count % 50 == 0)
                {
                    game.enemyBullets.Add(new EnemyBullet(x, y, MyRandom.PlusMinus(15 * MyMath.Deg2Rad) + angleToPlayer, 8f));
                }
            }
            else if (gunID == 1)
            {//every 100 frames, shoots a shotgun blast of 10 bullets with varying speeds at the player, whithin an error of 45 degrees
                count++;
                if (count % 100 == 0)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        game.enemyBullets.Add(new EnemyBullet(x, y, MyRandom.PlusMinus(45 * MyMath.Deg2Rad) + angleToPlayer, MyRandom.Range(1, 8)));
                    }
                }
            }
            else if (gunID == 2)
            {//every 10 frames shoots in a random direction
                count++;
                if (count % 10 == 0)
                {
                    game.enemyBullets.Add(new EnemyBullet(x, y, MyRandom.PlusMinus(180 * MyMath.Deg2Rad), 8f));
                }
            }
            else if (gunID == 3)
            {//for 10 frames shoo in a circular pattern, resets after 40 frames
                count++;
                if (count < 10)
                {
                    game.enemyBullets.Add(new EnemyBullet(x, y, count * 36 * MyMath.Deg2Rad, count));
                }
                if (count > 50)
                {
                    count = 0;
                }
            }
        }
Exemple #8
0
 public void Update()
 {
     if (state == State.Normal)
     {
         if (enemySpawnCount < maxEnemyCount)
         {
             if (game.enemies.Count < waveCount * 2)
             {
                 enemySpawnCount++;
                 screenSpawnPosition = MyRandom.Range(0, 4); //spawn enemy from one side
                 if (screenSpawnPosition == 0)
                 {
                     game.enemies.Add(new Zako3(game, Screen.Width, MyRandom.Range(0, Screen.Height), HPMultiplier));
                     if (MyRandom.Range(0, 20) == 0)
                     {
                         game.enemies.Add(new Zako4(game, Screen.Width, MyRandom.Range(0, Screen.Height), HPMultiplier));
                     }
                 }
                 if (screenSpawnPosition == 1)
                 {
                     game.enemies.Add(new Zako3(game, -64, MyRandom.Range(0, Screen.Height), HPMultiplier));
                     if (MyRandom.Range(0, 20) == 0)
                     {
                         game.enemies.Add(new Zako4(game, -64, MyRandom.Range(0, Screen.Height), HPMultiplier));
                     }
                 }
                 if (screenSpawnPosition == 2)
                 {
                     game.enemies.Add(new Zako3(game, MyRandom.Range(0, Screen.Width), Screen.Height, HPMultiplier));
                     if (MyRandom.Range(0, 20) == 0)
                     {
                         game.enemies.Add(new Zako4(game, MyRandom.Range(0, Screen.Width), Screen.Height, HPMultiplier));
                     }
                 }
                 else
                 {
                     game.enemies.Add(new Zako3(game, MyRandom.Range(0, Screen.Width), -64, HPMultiplier));
                     if (MyRandom.Range(0, 20) == 0)
                     {
                         game.enemies.Add(new Zako4(game, MyRandom.Range(0, Screen.Width), -64, HPMultiplier));
                     }
                 }
             }
         }
         if (enemySpawnCount >= maxEnemyCount && game.enemies.Count == 0)
         {
             for (int i = 0; i < waveCount; i++)
             {
                 screenSpawnPosition = MyRandom.Range(0, 4);
                 if (screenSpawnPosition == 0)
                 {
                     game.enemies.Add(new Boss2(game, Screen.Width, MyRandom.Range(0, Screen.Height), this, HPMultiplier));
                 }
                 else if (screenSpawnPosition == 1)
                 {
                     game.enemies.Add(new Boss2(game, 0, MyRandom.Range(0, Screen.Height), this, HPMultiplier));
                 }
                 else if (screenSpawnPosition == 2)
                 {
                     game.enemies.Add(new Boss2(game, MyRandom.Range(0, Screen.Width), Screen.Height, this, HPMultiplier));
                 }
                 else
                 {
                     game.enemies.Add(new Boss2(game, MyRandom.Range(0, Screen.Width), 0, this, HPMultiplier));
                 }
             }
             state = State.Boss;
         }
     }
     if (state == State.Boss)
     {
         if (game.enemies.Count == 0)
         {
             if (game.gameType == Game.GameType.Endless)
             {
                 waveCount++;
                 maxEnemyCount *= waveCount;
             }
             if (game.gameType == Game.GameType.EndlessHP)
             {
                 HPMultiplier++;
             }
             enemySpawnCount = 0;
             state           = State.Normal;
         }
     }
 }
Exemple #9
0
        public override void Update()
        {
            if (state == State.Appear)
            {
                x -= 5;

                if (x <= 750)
                {
                    state = State.Normal;
                }
            }
            else if (state == State.Normal)
            {
                if (playerY > y)
                {
                    y += 1;
                }
                if (playerY < y)
                {
                    y -= 1;
                }
                x += (float)Math.Cos((bulletCount * 3) * MyMath.Deg2Rad);
                y += (float)Math.Sin((bulletCount * 3) * MyMath.Deg2Rad);

                bulletCount++;
                if (bulletCount == 100)
                {
                    for (int i = 0; i < 50; i++)
                    {
                        game.enemyBullets.Add(new EnemyBullet(x, y, MyRandom.Range(150, 210) * MyMath.Deg2Rad, MyRandom.Range(1f, 8f)));
                    }
                    bulletCount = 0;
                }

                if (playerX > x)
                {
                    for (int i = 0; i < 20; i++)
                    {
                        game.enemyBullets.Add(new EnemyBullet(x, y, MyRandom.PlusMinus(45) * MyMath.Deg2Rad, MyRandom.Range(1f, 8f)));
                    }
                }
            }
            else if (state == State.Swoon)
            {
                swoonTime--;

                if (swoonTime <= 0)
                {
                    state = State.Angry;
                }
            }
            else if (state == State.Angry)
            {
                specialAbilityCount++;
                if (specialAbilityCount < 100)
                {
                    if (specialAbilityCount % 2 == 0)
                    {
                        x = x + specialAbilityCount;
                    }
                    if (specialAbilityCount % 2 == 1)
                    {
                        x = x - specialAbilityCount;
                    }
                }
                if (specialAbilityCount == 100)
                {
                    x = Screen.Width + 100;
                }
                if (specialAbilityCount == 150)
                {
                    x = MyRandom.Range(0, Screen.Width);
                    y = MyRandom.Range(0, Screen.Height);
                    for (int i = 0; i < 360; i += 20)
                    {
                        game.enemyBullets.Add(new EnemyBullet(x, y, i * MyMath.Deg2Rad, 8f));
                    }
                    for (int i = 10; i < 360; i += 20)
                    {
                        game.enemyBullets.Add(new EnemyBullet(x, y, i * MyMath.Deg2Rad, 4f));
                    }
                }
                if (specialAbilityCount == 200)
                {
                    specialAbilityCount = 0;
                }
            }
            else if (state == State.Dying)
            {
                dyingTime--;
                y     += .2f;
                angle += .2f * MyMath.Deg2Rad;
                x      = MyRandom.Range(x - 2f, x + 2f);

                if (dyingTime % 4 == 0)
                {
                    game.explosions.Add(new Explosion(
                                            MyRandom.Range(x - Size / 2, x + Size / 2),
                                            MyRandom.Range(y - Size / 2, y + Size / 2)));
                }

                if (dyingTime <= 0)
                {
                    isDead = true;
                    for (int i = 0; i < 25; i++)
                    {
                        game.explosions.Add(new Explosion(
                                                MyRandom.Range(x - Size / 2, x + Size / 2),
                                                MyRandom.Range(y - Size / 2, y + Size / 2)));
                    }
                }
            }
        }
Exemple #10
0
        public void Update()
        {
            Input.Update(); //updates inputs

            if (state == State.Title)
            {
                Sound.BGM(Sound.BGMMenu); //play menu music when returning to title screen

                if (Input.GetButtonDown(DX.PAD_INPUT_8) || Input.GetButtonDown(DX.PAD_INPUT_UP))
                {//move up
                    Sound.Play(Sound.menuMovement);
                    menuCount--;
                    if (menuCount < 0)
                    {
                        menuCount = 4;                //loop
                    }
                }
                else if (Input.GetButtonDown(DX.PAD_INPUT_5) || Input.GetButtonDown(DX.PAD_INPUT_DOWN))
                {//move down
                    Sound.Play(Sound.menuMovement);
                    menuCount++;
                    if (menuCount > 4)
                    {
                        menuCount = 0;
                    }
                }

                //Pressing Z triggers the bool which in turn activates the 'countdown'
                //once the 'countdown' counts 60 frames, activate selected option
                if (Input.GetButtonDown(DX.PAD_INPUT_1))
                {
                    Sound.Play(Sound.menuSelect);
                    optionSelected = true;
                }
                if (optionSelected)
                {
                    startCountDown++;
                }
                if (menuCount == 0 && startCountDown == 60)
                {                           //Normal mode
                    state          = State.Restart;
                    optionSelected = false; //reset bool
                    startCountDown = 0;     //reset 'countdown'
                    gameType       = GameType.Normal;
                }
                if (menuCount == 1 && startCountDown == 60)
                {//Endless mode
                    state          = State.Restart;
                    optionSelected = false;
                    startCountDown = 0;
                    gameType       = GameType.Endless;
                }
                if (menuCount == 2 && startCountDown == 60)
                {//Endless mode - HP
                    state          = State.Restart;
                    optionSelected = false;
                    startCountDown = 0;
                    gameType       = GameType.EndlessHP;
                }
                if (menuCount == 3 && startCountDown == 60)
                {//Help
                    optionSelected = false;
                    startCountDown = 0;
                    state          = State.Help;
                }
                if (menuCount == 4 && startCountDown == 60)
                {//Options
                    optionSelected = false;
                    startCountDown = 0;
                    state          = State.Options;
                }
            }

            if (state == State.Options)
            {
                if (Input.GetButtonDown(DX.PAD_INPUT_2) && option == Option.Neutral)
                {//go back to menu
                    Sound.Play(Sound.cancel);
                    state = State.Title;
                }

                //Cicle through the options
                if (option == Option.Neutral)
                {
                    if (Input.GetButtonDown(DX.PAD_INPUT_8) || Input.GetButtonDown(DX.PAD_INPUT_UP))
                    {//Up
                        Sound.Play(Sound.menuMovement);
                        optionCount--;
                        if (optionCount < 0)
                        {
                            optionCount = 2;
                        }
                    }
                    else if (Input.GetButtonDown(DX.PAD_INPUT_5) || Input.GetButtonDown(DX.PAD_INPUT_DOWN))
                    {//down
                        Sound.Play(Sound.menuMovement);
                        optionCount++;
                        if (optionCount > 2)
                        {
                            optionCount = 0;
                        }
                    }
                }

                //If music option was selected
                if (Input.GetButtonDown(DX.PAD_INPUT_1) && optionCount == 0)
                {
                    option = Option.Music;
                }
                if (option == Option.Music)
                {     //now the player can cicle through the song list
                    if (Input.GetButtonDown(DX.PAD_INPUT_2))
                    { //back out of music selection
                        Sound.Play(Sound.cancel);
                        option = Option.Neutral;
                    }
                    if (Input.GetButtonDown(DX.PAD_INPUT_8) || Input.GetButtonDown(DX.PAD_INPUT_UP))
                    {//scroll list up
                        Sound.Play(Sound.menuMovement);
                        musicCount--;
                        if (musicCount < 0)
                        {
                            musicCount = 3;
                        }
                    }
                    else if (Input.GetButtonDown(DX.PAD_INPUT_5) || Input.GetButtonDown(DX.PAD_INPUT_DOWN))
                    {//scroll list down
                        Sound.Play(Sound.menuMovement);
                        musicCount++;
                        if (musicCount > 3)
                        {
                            musicCount = 0;
                        }
                    }
                    if (Input.GetButtonDown(DX.PAD_INPUT_1))
                    {//select music that will be played during the game
                        Sound.Play(Sound.menuSelect);
                        if (musicCount == 0)
                        {
                            Sound.musicID = 0;
                        }
                        if (musicCount == 1)
                        {
                            Sound.musicID = 1;
                        }
                        if (musicCount == 2)
                        {
                            Sound.musicID = 2;
                        }
                        if (musicCount == 3)
                        {
                            Sound.musicID = 3;
                        }
                        Sound.SetMusic();
                    }
                }

                //if BGM volume option was selected
                if (Input.GetButtonDown(DX.PAD_INPUT_1) && optionCount == 1)
                {
                    option = Option.BGMVolume;
                    Sound.Play(Sound.menuSelect);
                }
                if (option == Option.BGMVolume)
                {
                    if (Input.GetButtonDown(DX.PAD_INPUT_2))
                    {//back out of BGM Volume setting
                        Sound.Play(Sound.cancel);
                        option = Option.Neutral;
                    }
                    if (Input.GetButtonDown(DX.PAD_INPUT_4) || Input.GetButtonDown(DX.PAD_INPUT_LEFT))
                    {//press left to lower the volume by 10
                        Sound.Play(Sound.menuMovement);
                        Sound.BGMVolume -= 10;
                        if (Sound.BGMVolume < 0)
                        {
                            Sound.BGMVolume = 0;
                        }
                        Sound.SetVolume(); //updates the sounds so they actually change volume
                    }
                    if (Input.GetButtonDown(DX.PAD_INPUT_6) || Input.GetButtonDown(DX.PAD_INPUT_RIGHT))
                    {//press right to increase the volume by 10
                        Sound.Play(Sound.menuMovement);
                        Sound.BGMVolume += 10;
                        if (Sound.BGMVolume > 200)
                        {
                            Sound.BGMVolume = 200;
                        }
                        Sound.SetVolume();
                    }
                }

                //if SE volume option was selected
                if (Input.GetButtonDown(DX.PAD_INPUT_1) && optionCount == 2)
                {
                    option = Option.SEVolume;
                    Sound.Play(Sound.menuSelect);
                }
                if (option == Option.SEVolume)
                {
                    if (Input.GetButtonDown(DX.PAD_INPUT_2))
                    {//back out of music selection
                        Sound.Play(Sound.cancel);
                        option = Option.Neutral;
                    }
                    if (Input.GetButtonDown(DX.PAD_INPUT_4) || Input.GetButtonDown(DX.PAD_INPUT_LEFT))
                    {//press left to lower the volume by 10
                        Sound.Play(Sound.menuMovement);
                        Sound.SEVolume -= 10;
                        if (Sound.SEVolume < 0)
                        {
                            Sound.SEVolume = 0;
                        }
                        Sound.SetVolume();
                    }
                    if (Input.GetButtonDown(DX.PAD_INPUT_6) || Input.GetButtonDown(DX.PAD_INPUT_RIGHT))
                    {//press right to increase the volume by 10
                        Sound.Play(Sound.menuMovement);
                        Sound.SEVolume += 10;
                        if (Sound.SEVolume > 200)
                        {
                            Sound.SEVolume = 200;
                        }
                        Sound.SetVolume();
                    }
                }
            }

            if (state == State.Help)
            {
                if (Input.GetButtonDown(DX.PAD_INPUT_2))
                {
                    Sound.Play(Sound.cancel);
                    state = State.Title;
                }
            }

            if (state == State.Restart)
            {
                Restart();
            }

            if (state == State.Pause)
            {//Paused state, press Q again to un-pause
                if (Input.GetButtonDown(DX.PAD_INPUT_7))
                {
                    state = State.Game;
                }
                pause = true;
            }

            if (state == State.Game || state == State.End || state == State.Clear)
            {
                Sound.SetMusic(); //plays set music

                if (gameType == GameType.Normal)
                {
                    map.Scroll(scrollSpeed);
                    if (map.enemyCount == 0 && enemies.Count == 0)
                    {
                        state = State.Clear;
                    }
                }

                if (gameType == GameType.Endless || gameType == GameType.EndlessHP)
                {
                    wave.Update();
                }

                if (!player.isDead)
                {
                    mouse.Update();
                    player.Update();
                }
                else
                {
                    state = State.End;
                }

                foreach (PlayerBullet b in playerBullets)
                {
                    b.Update();
                }

                foreach (Enemy e in enemies)
                {
                    e.Update();
                }

                foreach (EnemyBullet b in enemyBullets)
                {
                    b.Update();
                }

                foreach (Item i in items)
                {
                    i.Update();
                }

                foreach (EnemyBullet enemyBullet in enemyBullets)
                {//player takes damage from enemy bullets
                    if (player.isDead)
                    {
                        break;
                    }

                    if (enemyBullet.isDead)
                    {
                        continue;
                    }

                    if (MyMath.SphereSphereIntersection(
                            player.x, player.y, player.collisionRadius,
                            enemyBullet.x, enemyBullet.y, enemyBullet.collisionRadius))
                    {
                        player.OnCollisionEnemyBullet(enemyBullet);
                    }
                }

                foreach (PlayerBullet playerBullet in playerBullets)
                {
                    if (playerBullet.isDead)
                    {
                        continue;
                    }

                    //for missiles
                    if (playerBullet is MissileBullet)
                    {
                        MissileBullet missile          = (MissileBullet)playerBullet;
                        float         shortestDistance = float.MaxValue;
                        foreach (Enemy enemy in enemies)
                        {//missile looks for closest enemy
                            if (MyMath.DistanceBetweenTwoPoints(missile.x, missile.y, enemy.x, enemy.y) < shortestDistance)
                            {
                                shortestDistance = MyMath.DistanceBetweenTwoPoints(missile.x, missile.y, enemy.x, enemy.y);
                                closeEnemyX      = enemy.x;
                                closeEnemyY      = enemy.y;
                            }
                            missile.AngleToEnemy(closeEnemyX, closeEnemyY);
                        }
                    }

                    //enemies take damage if hit by player bullet
                    foreach (Enemy enemy in enemies)
                    {
                        if (enemy.isDead)
                        {
                            continue;
                        }

                        if (enemy is Boss2)
                        {//if boss2 is in normal state (or when it is teleporting) it can't be hit by bullets - this way only the turrents can be hit
                            Boss2 boss = (Boss2)enemy;
                            if (boss.state == Boss2.State.Normal || boss.state == Boss2.State.Invincible)
                            {
                                continue;
                            }
                        }

                        if (MyMath.SphereSphereIntersection(
                                playerBullet.x, playerBullet.y, playerBullet.collisionRadius,
                                enemy.x, enemy.y, enemy.collisionRadius))
                        {
                            enemy.OnCollisionPlayerBullet(playerBullet);
                            playerBullet.OnCollisionEnemy(enemy);

                            if (playerBullet.isDead)
                            {
                                break;
                            }
                        }
                    }
                }

                foreach (Enemy enemy in enemies)
                {
                    if (player.isDead)
                    {
                        break;
                    }

                    if (enemy.isDead)
                    {
                        continue;
                    }

                    if (enemy is Boss2)
                    {//can't hurt player when boss is teleporting
                        Boss2 boss = (Boss2)enemy;
                        if (boss.state == Boss2.State.Invincible)
                        {
                            continue;
                        }
                    }

                    if (MyMath.SphereSphereIntersection(
                            player.x, player.y, player.collisionRadius,
                            enemy.x, enemy.y, enemy.collisionRadius))
                    {
                        player.OnCollisionEnemy(enemy);
                        enemy.OnCollisionPlayer();
                    }

                    enemy.OutOfBoundsKillFlag(); //enemies are removed if they are outside the boundaries for too long
                }

                //this decides item drop chance and score
                foreach (Enemy enemy in enemies)
                {
                    if (enemy.isDead)
                    {
                        //items have a 1 in 10 chance to drop something
                        int itemDrop = MyRandom.Range(0, 10);
                        if (itemDrop == 0)
                        {
                            items.Add(new HealthItem(enemy));
                        }
                        if (itemDrop == 1)
                        {
                            items.Add(new StrightBulletPowerUpItem(enemy));
                        }
                        if (itemDrop == 2)
                        {
                            items.Add(new SpreadBulletPowerUpItem(enemy));
                        }
                        if (itemDrop == 3)
                        {
                            items.Add(new MissileBulletPowerUpItem(enemy));
                        }

                        //most enemies are worth 10 points, 1 type of enemy is worth 20, and the boss is worth 100
                        //Note - points for mines and boss turrents are calculated in Zako4 and Boss2 respectivly
                        if (enemy is Zako0 || enemy is Zako1 || enemy is Zako2 || enemy is Zako3)
                        {
                            score += 10;
                        }
                        if (enemy is Zako4)
                        {
                            score += 20;
                        }
                        if (enemy is Boss2)
                        {
                            score += 100;
                        }
                    }
                }

                //updates items and detects if the player picks them up
                foreach (Item item in items)
                {
                    if (player.isDead)
                    {
                        break;
                    }

                    if (item.isDead)
                    {
                        continue;
                    }

                    if (MyMath.SphereSphereIntersection(
                            player.x, player.y, player.collisionRadius,
                            item.x, item.y, item.collisionRadius))
                    {
                        player.OnCollisionItem(item);
                        item.OnCollisionPlayer(player);
                    }
                }

                foreach (Explosion e in explosions)
                {
                    e.Update();
                }

                //removes all assets that are no longer used
                playerBullets.RemoveAll(pb => pb.isDead);
                enemies.RemoveAll(e => e.isDead);
                enemyBullets.RemoveAll(eb => eb.isDead);
                explosions.RemoveAll(e => e.isDead);
                items.RemoveAll(i => i.isDead);

                if (state == State.End || state == State.Clear)
                {//only save score if the player finishes or dies on a stage
                    //if current score is higher then max score, change max score to the current score
                    if (gameType == GameType.Normal && score > maxScore0)
                    {
                        maxScore0 = score;
                    }
                    if (gameType == GameType.Endless && score > maxScore1)
                    {
                        maxScore1 = score;
                    }
                    if (gameType == GameType.EndlessHP && score > maxScore2)
                    {
                        maxScore2 = score;
                    }
                }

                //player can reset or go back to the title screen at any time
                if (Input.GetButtonDown(DX.PAD_INPUT_1))
                {
                    state = State.Restart;
                }
                if (Input.GetButtonDown(DX.PAD_INPUT_2))
                {
                    state = State.Title;
                }

                //Press Q to pause
                if (Input.GetButtonDown(DX.PAD_INPUT_7) && pause == false)
                {
                    state = State.Pause;
                }
                if (pause == true)
                {
                    pause = false;
                }
            }
        }