void UpdateTitleScreen(GameTime gameTime)
        {
            //this is a mess because it's the same everytime and it isn't important enough to not hardcode everything
            elapsedtime += (float)gameTime.ElapsedGameTime.TotalSeconds;
            input.Update();
            //if (soundlistinstance[9].State != SoundState.Playing)
            //{
            //    soundlistinstance[9].IsLooped = true;
            //    soundlistinstance[9].Play();
            //}
            if (numAsteroid == 0)
            {
                numAsteroid++;
                spawner.NewItem(newobject, objectlist, asteroidIdle, 1, ranGen);
                objectlist[0].Speed  = new Vector2(0, 0);
                objectlist[0].XPos   = GraphicsDeviceManager.DefaultBackBufferWidth / 2;
                objectlist[0].YPos   = GraphicsDeviceManager.DefaultBackBufferHeight / 2;
                objectlist[0].Scale  = 4;
                objectlist[0].Rotate = 0.01f;
                spawner.NewItem(newobject, objectlist, alienIdle, 2, ranGen);
                objectlist[1].Speed = new Vector2(-1, 0);
                objectlist[1].YPos  = 20;
                myShip.Speed        = new Vector2(0.5f, 0);
                myShip.XPos         = 0;
                myShip.YPos         = GraphicsDeviceManager.DefaultBackBufferHeight - 100;
                myShip.Scale        = 1;
                myShip.rotation     = MathHelper.Pi / 2;
            }
            objectlist[1].shotcooldown -= (float)gameTime.ElapsedGameTime.TotalSeconds;
            ai.Think(objectlist[1], myShip, controller, EnemyBulletParticles, soundlistinstance[0]);
            objectlist[0].Update();
            objectlist[1].Update();
            myShip.Update();
            controller.Rotate(objectlist[0], objectlist[0].Rotate);
            controller.Update(objectlist[1]);
            controller.Update(myShip);

            if (elapsedtime % 10 < 0.1)
            {
                controller.Shoot(myShip, PlayerBulletParticles, soundlistinstance[0]);
            }
            PlayerBulletParticles.Update();
            EnemyBulletParticles.Update();
            if (input.WasKeyPressed(Keys.Enter) || input.WasButtonPressed(Buttons.Start))
            {
                //soundlistinstance[9].Stop();
                elapsedtime = 0;
                RemoveEnemies();
                myShip.Scale = 0;
                _state       = GameState.Gameplay;
                Reinitialize();
            }
        }
 bool CheckParticleCollision(Collision sprite1, ParticleManager particles)
 {
     for (int particle = 0; particle < particles.particles.Count; particle++)
     {
         sprite2 = particles.GetCollider(particle);
         if (sprite1.visiblePixelCollision(sprite2))
         {
             particles.Kill(particle);
             particles.Update();
             particle--;
             return(true);
         }
     }
     return(false);
 }
        void UpdateGameplay(GameTime gameTime)
        {
            //if (soundlistinstance[10].State != SoundState.Playing)
            //{
            //    soundlistinstance[10].Volume = 0.1f;
            //    soundlistinstance[10].IsLooped = true;
            //    soundlistinstance[10].Play();
            //}

            //main gameplay loop for each gametype
            elapsedtime += (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (CheckObjectiveComplete())
            {
                RemoveEnemies();
                if (hud.objective == "")
                {
                    InitializeNewGame();
                }
                else
                {
                    myPortal.Scale = 1;
                }
            }
            if (extralifecounter > 10000)
            {
                extralifecounter = 0;
                hud.lives++;
                soundlist[6].Play();
            }

            if (hud.lives <= 0)
            {
                //soundlistinstance[10].Stop();
                _state = GameState.HighScores;
                RemoveEnemies();
                Update(gameTime);
            }
            Respawn();

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

            if (myShip.Scale == 1)
            {
                //if the ships scale isn't one that means that the player is currently dead so inputs aren't needed.
                input.Update();
                if (input.UpdateThumbStickAngle() != 0)
                {
                    controller.RotateTo(myShip, input.UpdateThumbStickAngle());
                }
                if (input.IsKeyDown(Keys.Left))
                {
                    controller.Rotate(myShip, -0.05f);
                }
                if (input.IsKeyDown(Keys.Right))
                {
                    controller.Rotate(myShip, 0.05f);
                }
                if (input.IsKeyDown(Keys.Up) || input.IsButtonDown(Buttons.RightTrigger))
                {
                    soundlistinstance[6].IsLooped = true;
                    soundlistinstance[6].Play();
                    myShip.setCurrentAction("Moving");
                    controller.Move(myShip);
                }
                else if (input.isMouseButtonDown(1))
                {
                    soundlistinstance[6].IsLooped = true;
                    soundlistinstance[6].Play();
                    myShip.setCurrentAction("Moving");
                    Vector2 mouse = input.getMousePos();
                    float   angle = (float)((Math.Atan2(mouse.Y - myShip.YPos, mouse.X - myShip.XPos) + MathHelper.Pi / 2));
                    controller.RotateTo(myShip, angle);
                    controller.Move(myShip);
                }
                else
                {
                    soundlistinstance[6].Pause();
                    myShip.setCurrentAction("Idle");
                    controller.Stop(myShip);
                }
                if (input.isMouseButtonDown(2))
                {
                    Vector2 mouse = input.getMousePos();
                    float   angle = (float)((Math.Atan2(mouse.Y - myShip.YPos, mouse.X - myShip.XPos) + MathHelper.Pi / 2));
                    controller.RotateTo(myShip, angle);
                }
                if (input.WasKeyPressed(Keys.Space) || input.WasButtonPressed(Buttons.A))
                {
                    controller.Shoot(myShip, PlayerBulletParticles, soundlistinstance[0]);
                }
                else if (input.isMouseButtonClick(2))
                {
                    Vector2 mouse = input.getMousePos();
                    float   angle = (float)((Math.Atan2(mouse.Y - myShip.YPos, mouse.X - myShip.XPos) + MathHelper.Pi / 2));
                    controller.RotateTo(myShip, angle);
                    controller.Shoot(myShip, PlayerBulletParticles, soundlistinstance[0]);
                }
            }

            controller.Update(myShip);
            myShip.Update();
            PlayerBulletParticles.Update();
            EnemyBulletParticles.Update();
            ParticleEffects.Update();

            //this causes the game to pause for 2 seconds before starting each time it changes gametype
            if (elapsedtime > 2)
            {
                if (hud.objective != "DESTROY ALL ASTEROIDS" && hud.objective != "DESTROY ALL ALIENS")
                {
                    if (elapsedtime % (10 - Difficulty.difficulty) < gameTime.ElapsedGameTime.TotalSeconds)
                    {
                        //spawns asteroids every 10 seconds to begin with and increases the spawning rate as time goes on
                        spawner.NewItem(newobject, objectlist, asteroidIdle, 1, ranGen);
                        numAsteroid++;
                        if (hud.objective == "")
                        {
                            //everytime an asteroid is spawned in the tutorial the difficulty increases
                            Difficulty.difficulty++;
                        }
                    }
                    if (elapsedtime % (12 - Difficulty.difficulty) < gameTime.ElapsedGameTime.TotalSeconds)
                    {
                        //spawns aliens every 12 seconds to begin with and increases the spawning rate as time goes on
                        spawner.NewItem(newobject, objectlist, alienIdle, 2, ranGen);
                        numAliens++;
                        if (ranGen.Next(1, 4) > 3)
                        {
                            //25% chance of spawning a small alien.
                            objectlist[objectlist.Count - 1].Scale = 0.5f;
                        }
                    }
                }

                timesincelasthit += (float)gameTime.ElapsedGameTime.TotalSeconds;
                UpdateList(objectlist, newobject, gameTime);
                sprite1 = myShip.GetCollider();
                if (timesincelasthit > 2)
                {
                    //the player is invincble for 2 seconds after being hit
                    if (CheckParticleCollision(sprite1, EnemyBulletParticles))
                    {
                        GenerateParticleEffects(myShip);
                        hud.lives--;
                        myShip.Scale     = 0;
                        timesincelasthit = 0;
                        soundlist[2].Play();
                    }
                }

                if (myPortal.Scale == 1)
                {
                    //after the objective is completed a portal spawns and sucks the player into it.

                    if (lastPlayed == 7 && soundlistinstance[7].State == SoundState.Stopped)
                    {
                        soundlistinstance[8].Play();
                        lastPlayed = 8;
                    }
                    else if (soundlistinstance[8].State == SoundState.Stopped)
                    {
                        soundlistinstance[7].Play();
                        lastPlayed = 7;
                    }
                    controller.Move(myShip, (float)(Math.Atan2(myShip.YPos - myPortal.YPos, myShip.XPos - myPortal.XPos) + MathHelper.Pi / 2), -1);
                    myPortal.Update();
                    sprite2 = myPortal.GetCollider();
                    if (sprite1.visiblePixelCollision(sprite2))
                    {
                        soundlistinstance[8].Stop();
                        myPortal.Scale = 0;
                        InitializeNewGame();
                    }
                }
            }

            if (hud.objective == "DESTROY ALL ALIENS")
            {
                hud.objectivenumber = numAliens;
            }
            if (hud.objective == "DESTROY ALL ASTEROIDS")
            {
                hud.objectivenumber = numAsteroid;
            }
            if (hud.objective == "COLLECT")
            {
                hud.objectivenumber = numStars;
            }
            hud.Update(gameTime);
        }