private void handleBullets()
        {
            //bullet stuff
            if (bulletQueue.Count > 0)
            {
                tempBulletArray = bulletQueue.ToArray();
                bulletQueue.Clear();                                  //convert to array, clear the queue and fill it up after changes

                for (int i = 0; i < tempBulletArray.Length; i++)
                {
                    ((Bullet)tempBulletArray.GetValue(i)).CurrentPos += ((Bullet)tempBulletArray.GetValue(i)).DirectionIncrement;

                    bulletQueue.Enqueue((Bullet)tempBulletArray.GetValue(i));
                }

                if (((Bullet)bulletQueue.Peek()).isDead())        //remove dead bullets from the queue
                {
                    bulletQueue.Dequeue();
                }

                tempBulletArray = bulletQueue.ToArray();
            }

            //this is the frame where the bullet is created
            if (animation.currentFrame == 18 && bulletAdded == false && (activity == EnemyActivity2.enemyShootDown || activity == EnemyActivity2.enemyShootDiagDown || activity == EnemyActivity2.enemyShootAhead || activity == EnemyActivity2.enemyShootDiagUp || activity == EnemyActivity2.enemyShootUp))
            {
                Bullet bullet = new Bullet();

                if (MainMenuScreen.currentGameScreen == 1)
                {
                    bullet.Texture = GameplayScreen.bulletTex2;
                }
                else
                {
                    bullet.Texture = GameplayScreen2.bulletTex2;
                }

                if(animation.myEffect == SpriteEffects.FlipHorizontally)  //to the right
                {
                    if (activity == EnemyActivity2.enemyShootDown)
                    {
                        bullet.DirectionIncrement = new Vector2(0f, 1f);
                        bullet.Origin = Position + new Vector2(21f, 70f);
                    }
                    else if (activity == EnemyActivity2.enemyShootDiagDown)
                    {
                        bullet.DirectionIncrement = new Vector2(0.75f, 0.75f);
                        bullet.Origin = Position + new Vector2(60f, 50f);
                    }
                    else if (activity == EnemyActivity2.enemyShootAhead)
                    {
                        bullet.DirectionIncrement = new Vector2(1f, 0f);
                        bullet.Origin = Position + new Vector2(90f, -5f);
                    }
                    else if (activity == EnemyActivity2.enemyShootDiagUp)
                    {
                        bullet.DirectionIncrement = new Vector2(0.75f, -0.75f);
                        bullet.Origin = Position + new Vector2(65f, -73f);
                    }
                    else if (activity == EnemyActivity2.enemyShootUp)
                    {
                        bullet.DirectionIncrement = new Vector2(0f, -1f);
                        bullet.Origin = Position + new Vector2(2f, -100f);
                    }
                }
                else   //to the left
                {
                    if (activity == EnemyActivity2.enemyShootDown)
                    {
                        bullet.DirectionIncrement = new Vector2(0f, 1f);
                        bullet.Origin = Position + new Vector2(-35f, 70f);
                    }
                    else if (activity == EnemyActivity2.enemyShootDiagDown)
                    {
                        bullet.DirectionIncrement = new Vector2(-0.75f, 0.75f);
                        bullet.Origin = Position + new Vector2(-87f, 58f);
                    }
                    else if (activity == EnemyActivity2.enemyShootAhead)
                    {
                        bullet.DirectionIncrement = new Vector2(-1f, 0f);
                        bullet.Origin = Position + new Vector2(-90f, -5f);
                    }
                    else if (activity == EnemyActivity2.enemyShootDiagUp)
                    {
                        bullet.DirectionIncrement = new Vector2(-0.75f, -0.75f);
                        bullet.Origin = Position + new Vector2(-77f, -75f);
                    }
                    else if (activity == EnemyActivity2.enemyShootUp)
                    {
                        bullet.DirectionIncrement = new Vector2(0f, -1f);
                        bullet.Origin = Position + new Vector2(-16f, -100f);
                    }
                }

                bullet.MaxDistanceFromOrigin = 1500;
                bullet.Speed = 6;
                bullet.CurrentPos = bullet.Origin;
                bullet.DirectionIncrement *= bullet.Speed;

                bulletQueue.Enqueue(bullet);    //add the bullet to the queue of bullets

                bulletAdded = true;

                soundEffectInstance = GameStateManagementGame.bearShoot.CreateInstance();        //play bullet sound quitely if far away

                if (MainMenuScreen.currentGameScreen == 1)
                {
                    soundEffectInstance.Apply3D(GameplayScreen.audioListener, audioEmitter);
                    soundEffectInstance.Play();
                }
                else
                {
                    soundEffectInstance.Apply3D(GameplayScreen2.audioListener, audioEmitter);
                    soundEffectInstance.Play();
                }
            }

            if (animation.currentFrame > 18 && (activity == EnemyActivity2.enemyShootDown || activity == EnemyActivity2.enemyShootDiagDown || activity == EnemyActivity2.enemyShootAhead || activity == EnemyActivity2.enemyShootDiagUp || activity == EnemyActivity2.enemyShootUp))
            {
                bulletAdded = false;
            }
        }
        private void HandleGamePad()
        {
            GamePadState padState = GamePad.GetState(PlayerIndex.One, GamePadDeadZone.Circular);

            //bullet stuff
            if (bulletQueue.Count > 0)
            {
                tempBulletArray = bulletQueue.ToArray();
                bulletQueue.Clear();                                  //convert to array, clear the queue and fill it up after changes

                for (int i = 0; i < tempBulletArray.Length; i++)
                {
                    ((Bullet)tempBulletArray.GetValue(i)).CurrentPos += ((Bullet)tempBulletArray.GetValue(i)).DirectionIncrement;

                    bulletQueue.Enqueue((Bullet)tempBulletArray.GetValue(i));
                }

                if (((Bullet)bulletQueue.Peek()).isDead())        //remove dead bullets from the queue
                {
                    bulletQueue.Dequeue();
                }

                tempBulletArray = bulletQueue.ToArray();
            }

            //back button resets the player
            if (box.activity == Activity.Dead && padState.Buttons.Back == ButtonState.Pressed && _oldPadState.Buttons.Back == ButtonState.Released && padState.IsConnected)
            {
                GamePad.SetVibration(PlayerIndex.One, 0.0f, 0.0f);

                MainMenuScreen.gamePlayScreen2.killAllEnemyThreads();

                MainMenuScreen.gamePlayScreen2 = new GameplayScreen2();

                LoadingScreen.Load(ScreenManager, true, 0, MainMenuScreen.gamePlayScreen2);
            }

            if (padState.IsConnected && box.activity != Activity.Dead)
            {

                if (padState.Buttons.B == ButtonState.Pressed && _oldPadState.Buttons.B == ButtonState.Released)
                {
                    /*if (showBox == true)
                    {
                        showBox = false;
                    }
                    else
                    {
                        showBox = true;
                    }   */
                }

                if (padState.Triggers.Right > 0.5 && _oldPadState.Triggers.Right < 0.5)
                {
                    if (ammo > 0)
                    {
                        GameStateManagementGame.pistolSound.Play();

                        //vibration to the side of shooting
                        if (padState.ThumbSticks.Right.X < 0)
                        {
                            GamePad.SetVibration(PlayerIndex.One, Math.Abs(padState.ThumbSticks.Right.X / 2), 0.0f);
                        }
                        else
                        {
                            GamePad.SetVibration(PlayerIndex.One, 0.0f, (padState.ThumbSticks.Right.X / 2));
                        }

                        vibrationTime = 300;

                        Bullet bullet = new Bullet();
                        bullet.Texture = bulletTex;

                        if (padState.ThumbSticks.Right.X > 0.50 || padState.ThumbSticks.Right.X < -0.50 || padState.ThumbSticks.Right.Y > 0.50 || padState.ThumbSticks.Right.Y < -0.50)
                        {
                            bullet.DirectionIncrement = (padState.ThumbSticks.Right * new Vector2(1, -1));
                        }
                        else
                        {
                            if (armgunEffects == SpriteEffects.None)
                            {
                                bullet.DirectionIncrement = new Vector2(1, 0);
                            }
                            else if (armgunEffects == SpriteEffects.FlipHorizontally)
                            {
                                bullet.DirectionIncrement = new Vector2(-1, 0);
                            }
                        }

                        Vector2 perpToDirection;

                        //arm pivot point + direction multiplyed by guess number to bring the bullet origin to the tip of the pistol.
                        //also moved a few pixels 90 degrees perpendicular to direction to match the tip of the gun
                        if (armgunEffects == SpriteEffects.None)
                        {
                            perpToDirection = new Vector2(bullet.DirectionIncrement.Y, bullet.DirectionIncrement.X * -1) * 12;

                            bullet.Origin = new Vector2(box.Position.X + 10, box.Position.Y - 20) + (bullet.DirectionIncrement * 55) + perpToDirection;
                        }
                        else if (armgunEffects == SpriteEffects.FlipHorizontally)
                        {
                            perpToDirection = new Vector2(bullet.DirectionIncrement.Y * -1, bullet.DirectionIncrement.X) * 12;

                            bullet.Origin = new Vector2(box.Position.X - 20, box.Position.Y - 20) + (bullet.DirectionIncrement * 55) + perpToDirection;
                        }

                        bullet.CurrentPos = bullet.Origin;
                        bullet.DirectionIncrement *= bullet.Speed;

                        bulletQueue.Enqueue(bullet);    //add the bullet to the queue of bullets

                        ammo--;
                    }
                    else
                    {
                        GameStateManagementGame.clickSound.Play();
                    }
                }

                if (padState.ThumbSticks.Right.X > 0.50 || padState.ThumbSticks.Right.X < -0.50 || padState.ThumbSticks.Right.Y > 0.50 || padState.ThumbSticks.Right.Y < -0.50)
                {
                    armgunAngle = (float)Math.Atan2(padState.ThumbSticks.Right.Y, padState.ThumbSticks.Right.X) * -1;

                    armgunAngleInDegrees = (armgunAngle * 180) / Math.PI;

                    if (armgunAngleInDegrees > 90 || armgunAngleInDegrees < -90)
                    {
                        playerAnimation.myEffect = SpriteEffects.FlipHorizontally;
                        armgunEffects = SpriteEffects.FlipHorizontally;
                    }
                    else
                    {
                        playerAnimation.myEffect = SpriteEffects.None;
                        armgunEffects = SpriteEffects.None;
                    }
                }
                else
                {
                    armgunAngle = 0.0f;
                    headAngle = 0.0f;
                }

                //run animation speed is determined by the degree to which the analog stick is tilted
                if (box.activity == Activity.Running)
                {
                    if (padState.ThumbSticks.Left.X < -0.1f || padState.ThumbSticks.Left.X > 0.1f)
                    {
                        playerAnimation.frameTime = (int)(playerAnimation.minFrameTime * (1 / Math.Abs(padState.ThumbSticks.Left.X)));
                    }
                }

                //camera follow player
                if (freeViewOn == false)
                {
                    _cameraPosition = (box.Position - _screenCenter) * -1;
                    _cameraPosition += new Vector2(-130, 130);

                    //BG stuff..
                    bgPos.X += (_cameraPosition.X - oldCameraPos.X) / 9;           //move the bg slower then the foreground

                    if (bgPos.X > 1f)
                    {
                        bgPosB = bgPos - new Vector2(bg.Width, 0f);
                    }
                    else
                    {
                        bgPosB = bgPos + new Vector2(bg.Width, 0f);
                    }

                    if (bgPosB.X > 1f)
                    {
                        bgPos = bgPosB - new Vector2(bg.Width, 0f);
                    }
                    else
                    {
                        bgPos = bgPosB + new Vector2(bg.Width, 0f);
                    }

                    //Middle Ground Stuff...
                    mgPos.X += (_cameraPosition.X - oldCameraPos.X) / 4;

                    if (mgPos.X > 1f)
                    {
                        mgPosB = mgPos - new Vector2(mg.Width, 0f);
                    }
                    else
                    {
                        mgPosB = mgPos + new Vector2(mg.Width, 0f);
                    }

                    if (mgPosB.X > 1f)
                    {
                        mgPos = mgPosB - new Vector2(mg.Width, 0f);
                    }
                    else
                    {
                        mgPos = mgPosB + new Vector2(mg.Width, 0f);
                    }

                    bgPos.Y += (_cameraPosition.Y - oldCameraPos.Y) / 5;
                    bgPosB.Y = bgPos.Y;

                    mgYOffset += (_cameraPosition.Y - oldCameraPos.Y) / 10;
                    mgPos.Y = bgPos.Y + 920 + mgYOffset;
                    mgPosB.Y = mgPos.Y;

                    //move clouds
                    cloudsPos.X = (bgPos.X + 1280) + cloudIncrement;
                    cloudYOffset -= (_cameraPosition.Y - oldCameraPos.Y) / 30;
                    cloudsPos.Y = bgPos.Y + 200 + cloudYOffset;

                    cloudIncrement -= 0.4f;

                    if (cloudsPos.X < (-GameStateManagementGame.clouds.Width + -200))           //rest clouds once all shown
                    {
                        cloudIncrement = 300;
                    }

                    oldCameraPos = _cameraPosition;
                }

                _view = Matrix.CreateTranslation(new Vector3(_cameraPosition - _screenCenter, 0f)) * Matrix.CreateTranslation(new Vector3(_screenCenter, 0f));

                _oldPadState = padState;
            }
        }