Exemple #1
0
        private void UpdateEndOfGame(GameTime gameTime)
        {
            var mouseState = Mouse.GetState();
            var mousePoint = new Point(mouseState.X, mouseState.Y);

            if (returnToMainMenuButton.location.Contains(mousePoint))
            {
                returnToMainMenuButton.hover();
            }
            else
            {
                returnToMainMenuButton.unhover();
            }
            if (restartEndOfGameButton.location.Contains(mousePoint))
            {
                restartEndOfGameButton.hover();
            }
            else
            {
                restartEndOfGameButton.unhover();
            }

            if (returnToMainMenuButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
            {
                returnToMainMenuButton.press();
            }
            else if (restartEndOfGameButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
            {
                restartEndOfGameButton.press();
            }

            if (returnToMainMenuButton.isPressed)
            {
                if (returnToMainMenuButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    MediaPlayer.Stop();
                    MediaPlayer.Play(menuSong);
                    returnToMainMenuButton.unpress();
                    isPausePressed    = false;
                    _currentGameState = GameState.MainMenu;
                }
            }
            else if (restartEndOfGameButton.isPressed)
            {
                if (restartEndOfGameButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    restartEndOfGameButton.unpress();
                    isPausePressed = false;
                    RestartGame();
                    _currentGameState = GameState.GamePlay;
                }
            }
        }
Exemple #2
0
        private void UpdateMainMenu(GameTime gameTime)
        {
            this.IsMouseVisible = true;
            var mouseState = Mouse.GetState();
            var mousePoint = new Point(mouseState.X, mouseState.Y);

            #region ButtonsFunctionality
            if (!showSkinsWindow)
            {
                if (startButton.location.Contains(mousePoint))
                {
                    startButton.hover();
                }
                else
                {
                    startButton.unhover();
                }
                if (exitButton.location.Contains(mousePoint))
                {
                    exitButton.hover();
                }
                else
                {
                    exitButton.unhover();
                }
                if (skinsButton.location.Contains(mousePoint))
                {
                    skinsButton.hover();
                }
                else
                {
                    skinsButton.unhover();
                }

                if (startButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    startButton.press();
                }
                else if (exitButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    exitButton.press();
                }
                else if (skinsButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    skinsButton.press();
                }

                skin1Button.hideButton();
                skin2Button.hideButton();
                skin3Button.hideButton();
                skin4Button.hideButton();
                skin5Button.hideButton();
                selectedSkinCoverButton.hideButton();
            }
            if (showSkinsWindow)
            {
                if (skin1Button.location.Contains(mousePoint))
                {
                    skin1Button.hover();
                }
                else
                {
                    skin1Button.unhover();
                }
                if (skin2Button.location.Contains(mousePoint))
                {
                    skin2Button.hover();
                }
                else
                {
                    skin2Button.unhover();
                }
                if (skin3Button.location.Contains(mousePoint))
                {
                    skin3Button.hover();
                }
                else
                {
                    skin3Button.unhover();
                }
                if (skin4Button.location.Contains(mousePoint))
                {
                    skin4Button.hover();
                }
                else
                {
                    skin4Button.unhover();
                }
                if (skin5Button.location.Contains(mousePoint))
                {
                    skin5Button.hover();
                }
                else
                {
                    skin5Button.unhover();
                }

                if (skin1Button.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    skin1Button.press();
                }
                else if (skin2Button.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    skin2Button.press();
                }
                else if (skin3Button.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    skin3Button.press();
                }
                else if (skin4Button.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    skin4Button.press();
                }
                else if (skin5Button.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    skin5Button.press();
                }

                skin1Button.showHiddenButton();
                skin2Button.showHiddenButton();
                skin3Button.showHiddenButton();
                skin4Button.showHiddenButton();
                skin5Button.showHiddenButton();
                selectedSkinCoverButton.showHiddenButton();

                if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                {
                    showSkinsWindow = false;
                }
            }

            if (exitButton.isPressed)
            {
                if (exitButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    exitButton.unpress();
                    Exit();
                }
            }
            else if (startButton.isPressed)
            {
                if (startButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    startButton.unpress();
                    MediaPlayer.Stop();
                    MediaPlayer.Play(gameplaySong);
                    MediaPlayer.IsRepeating = true;
                    _currentGameState       = GameState.GamePlay;
                    RestartGame();
                }
            }
            else if (skinsButton.isPressed)
            {
                if (skinsButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    skinsButton.unpress();
                    showSkinsWindow = true;
                }
            }
            else if (skin1Button.isPressed)
            {
                if (skin1Button.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    skin1Button.unpress();
                    player.playerTexture = playerTexture;
                    missileTexture       = bulletSkin1;
                    currentBulletTexture = bulletSkin1;
                    selectedSkinCoverButton.location.Y = 0;
                }
            }
            else if (skin2Button.isPressed)
            {
                if (skin2Button.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    skin2Button.unpress();
                    player.playerTexture = spaceShipSkin2;
                    currentBulletTexture = bulletSkin2;
                    missileTexture       = bulletSkin2;
                    selectedSkinCoverButton.location.Y = 160;
                }
            }
            else if (skin3Button.isPressed)
            {
                if (skin3Button.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    skin3Button.unpress();
                    player.playerTexture = spaceShipSkin3;
                    currentBulletTexture = bulletSkin3;
                    missileTexture       = bulletSkin3;
                    selectedSkinCoverButton.location.Y = 320;
                }
            }
            else if (skin4Button.isPressed)
            {
                if (skin4Button.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    skin4Button.unpress();
                    player.playerTexture = spaceShipSkin4;
                    currentBulletTexture = bulletSkin4;
                    missileTexture       = bulletSkin4;
                    selectedSkinCoverButton.location.Y = 480;
                }
            }
            else if (skin5Button.isPressed)
            {
                if (skin5Button.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    skin5Button.unpress();
                    player.playerTexture = spaceShipSkin5;
                    missileTexture       = bulletSkin5;
                    currentBulletTexture = bulletSkin5;
                    selectedSkinCoverButton.location.Y = 640;
                }
            }
            #endregion
        }
Exemple #3
0
        private void UpdateGameplay(GameTime gameTime)
        {
            if (scroll1.location.Y + scroll1.location.Height >= 8192)
            {
                scroll1.location.Y = scroll2.location.Y - scroll2.backgroundTexture.Height;
            }
            if (scroll2.location.Y + scroll2.backgroundTexture.Height >= 8192)
            {
                scroll2.location.Y = scroll1.location.Y - scroll1.backgroundTexture.Height;
            }
            scroll1.Update();
            scroll2.Update();

            player.UpdateMovement();

            #region ButtonFunctionality

            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                isPausePressed      = true;
                this.IsMouseVisible = true;
                Pause();

                //TODO napisać funkcje pauzująca grę
            }

            var mouseState = Mouse.GetState();
            var mousePoint = new Point(mouseState.X, mouseState.Y);

            if (!showUpgradeWindow)
            {
                if (exitToMainMenuButton.location.Contains(mousePoint))
                {
                    exitToMainMenuButton.hover();
                }
                else
                {
                    exitToMainMenuButton.unhover();
                }
                if (resumeButton.location.Contains(mousePoint))
                {
                    resumeButton.hover();
                }
                else
                {
                    resumeButton.unhover();
                }
                if (restartButton.location.Contains(mousePoint))
                {
                    restartButton.hover();
                }
                else
                {
                    restartButton.unhover();
                }
                if (upgradeButton.location.Contains(mousePoint))
                {
                    upgradeButton.hover();
                }
                else
                {
                    upgradeButton.unhover();
                }

                if (exitToMainMenuButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    exitToMainMenuButton.press();
                }
                else if (resumeButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    resumeButton.press();
                }
                else if (restartButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    restartButton.press();
                }
                else if (upgradeButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    upgradeButton.press();
                }
                coinBackgroundButton.hideButton();
                oneShotButton.hideButton();
                piercingButton.hideButton();
                movementSpeedButton.hideButton();
                fireRateButton.hideButton();
            }
            if (showUpgradeWindow)
            {
                if (oneShotButton.location.Contains(mousePoint))
                {
                    oneShotButton.hover();
                }
                else
                {
                    oneShotButton.unhover();
                }
                if (piercingButton.location.Contains(mousePoint))
                {
                    piercingButton.hover();
                }
                else
                {
                    piercingButton.unhover();
                }
                if (movementSpeedButton.location.Contains(mousePoint))
                {
                    movementSpeedButton.hover();
                }
                else
                {
                    movementSpeedButton.unhover();
                }
                if (fireRateButton.location.Contains(mousePoint))
                {
                    fireRateButton.hover();
                }
                else
                {
                    fireRateButton.unhover();
                }

                if (oneShotButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    oneShotButton.press();
                }
                else if (piercingButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    piercingButton.press();
                }
                else if (movementSpeedButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    movementSpeedButton.press();
                }
                else if (fireRateButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed)
                {
                    fireRateButton.press();
                }

                coinBackgroundButton.showHiddenButton();
                oneShotButton.showHiddenButton();
                piercingButton.showHiddenButton();
                movementSpeedButton.showHiddenButton();
                fireRateButton.showHiddenButton();
                if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                {
                    showUpgradeWindow = false;
                }
            }

            if (exitToMainMenuButton.isPressed)
            {
                if (exitToMainMenuButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    MediaPlayer.Stop();
                    MediaPlayer.Play(menuSong);
                    exitToMainMenuButton.unpress();
                    isPausePressed    = false;
                    _currentGameState = GameState.MainMenu;
                }
            }
            else if (resumeButton.isPressed)
            {
                if (resumeButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    resumeButton.unpress();
                    isPausePressed = false;
                    Resume();
                }
            }
            else if (restartButton.isPressed)
            {
                if (restartButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    restartButton.unpress();
                    isPausePressed = false;
                    RestartGame();
                }
            }
            else if (upgradeButton.isPressed)
            {
                if (upgradeButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    upgradeButton.unpress();
                    showUpgradeWindow = true;
                }
            }
            else if (oneShotButton.isPressed)
            {
                if (oneShotButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    oneShotButton.unpress();
                    if (coinCount >= 5 && !isOneShotBought)
                    {
                        missileTexture = oneShotMissileTexture;
                        coinCount     -= 5;
                    }
                }
            }
            else if (piercingButton.isPressed)
            {
                if (piercingButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    piercingButton.unpress();
                    if (coinCount >= 3 && !isPiercingBought)
                    {
                        missileTexture = piercingMissileTexture;
                        coinCount     -= 3;
                    }
                }
            }
            else if (movementSpeedButton.isPressed)
            {
                if (movementSpeedButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    movementSpeedButton.unpress();
                    if (coinCount >= 1)
                    {
                        player.speed++;
                        coinCount--;
                    }
                }
            }
            else if (fireRateButton.isPressed)
            {
                if (fireRateButton.location.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Released)
                {
                    fireRateButton.unpress();
                    if (coinCount >= 1)
                    {
                        shootingSpeed++;
                        coinCount--;
                    }
                }
            }
            #endregion

            if (shooting)
            {
                //waves config
                if (actualScore > 100 && _currentEnemyWave == EnemyWave.First)
                {
                    throwSomeCoins    = true;
                    _currentEnemyWave = EnemyWave.Second;
                    enemySpeed        = 2;
                }
                else if (actualScore > 200 && _currentEnemyWave == EnemyWave.Second)
                {
                    throwSomeCoins    = true;
                    _currentEnemyWave = EnemyWave.Third;
                    enemySpeed        = 2;
                }
                else if (actualScore > 300 && _currentEnemyWave == EnemyWave.Third)
                {
                    throwSomeCoins    = true;
                    _currentEnemyWave = EnemyWave.Fourth;
                    enemySpeed        = 2;
                }
                else if (actualScore > 400 && _currentEnemyWave == EnemyWave.Fourth)
                {
                    throwSomeCoins    = true;
                    _currentEnemyWave = EnemyWave.Fifth;
                    enemySpeed        = 2;
                }
                //drawing missiles
                if (missiles.Count == 0)
                {
                    missiles.Add(new Missile(missileTexture, new Rectangle(player.playerLocation.X + player.playerLocation.Width / 2 - 5, player.playerLocation.Y, 10, 32), shootingSpeed));
                }
                else if (missiles[missiles.Count - 1].isNextReady(fireRate))
                {
                    missiles.Add(new Missile(missileTexture, new Rectangle(player.playerLocation.X + player.playerLocation.Width / 2 - 5, player.playerLocation.Y, 10, 32), shootingSpeed));
                }
                foreach (Missile m in missiles)
                {
                    //clearing destroyed missiles
                    if (m.isDestroyed)
                    {
                        missiles.Remove(m);
                        break;
                    }
                    else
                    {
                        m.Update();
                    }
                }

                //drawing enemies
                if (enemies.Count == 0)
                {
                    enemies.Add(new Enemy(enemyTexture1, enemyTexture2, enemyTexture3, enemyTexture4, enemyTexture5, new Rectangle(rnd.Next(500), -100, 100, 100), enemySpeed, _currentEnemyWave));
                }
                else if (enemies[enemies.Count - 1].isNextReady())
                {
                    enemies.Add(new Enemy(enemyTexture1, enemyTexture2, enemyTexture3, enemyTexture4, enemyTexture5, new Rectangle(rnd.Next(500), -100, 100, 100), enemySpeed, _currentEnemyWave));
                }
                foreach (Enemy e in enemies)
                {
                    //clearing destroyed enemies
                    if (e.isDestroyed)
                    {
                        enemies.Remove(e);
                        actualScore++;
                        break;
                    }
                    else
                    {
                        e.Update();
                    }

                    if (e.enemyLocation.Y > 800)
                    {
                        player.Hit();
                        e.isDestroyed = true;
                    }

                    if (player.health == 0)
                    {
                        Pause();
                        _currentGameState = GameState.EndOfGame;
                    }
                }

                //missiles collision detection
                foreach (Missile m in missiles)
                {
                    foreach (Enemy e in enemies)
                    {
                        if (e.enemyLocation.Contains(m.missileLocation))
                        {
                            if (missileTexture == oneShotMissileTexture)
                            {
                                e.Hit(500);
                            }
                            else if (missileTexture == piercingMissileTexture)
                            {
                                e.Hit(50);
                            }
                            else
                            {
                                e.Hit(25);
                            }

                            m.isDestroyed = true;
                            if (actualScore % 10 == 0 && enemySpeed != 5)
                            {
                                enemySpeed++;
                            }
                        }
                    }

                    foreach (TossACoin c in coins)
                    {
                        if (c.coinLocation.Contains(m.missileLocation))
                        {
                            c.isDestroyed = true;
                            coinCount++;
                        }
                    }
                }
                //update coins, check if out of screen
                foreach (TossACoin c in coins)
                {
                    if (c.isDestroyed)
                    {
                        coins.Remove(c);
                        break;
                    }
                    else
                    {
                        c.Update();
                    }
                }
                //drawing coins
                if (throwSomeCoins)
                {
                    coins.Add(new TossACoin(coinTexture, new Rectangle(rnd.Next(500), -90, 45, 55)));
                    coins.Add(new TossACoin(coinTexture, new Rectangle(rnd.Next(500), -150, 45, 55)));
                    coins.Add(new TossACoin(coinTexture, new Rectangle(rnd.Next(500), -210, 45, 55)));

                    throwSomeCoins = false;
                }
            }
            else if (isPausePressed == false)
            {
                shooting = true;
            }
        }
Exemple #4
0
        private void UpdateGameplay(GameTime deltaTime)
        {
            //game unpaused
            if (_gameplayState == GameplayState.Unpaused)
            {
                //update actual wave
                if (actualScore > 100 && actualWave == EnemyWave.First)
                {
                    actualWave = EnemyWave.Second;
                    startTime  = (int)deltaTime.TotalGameTime.TotalSeconds + 3;
                    enemySpeed = 2;
                    fireRate   = 210;
                }
                else if (actualScore > 200 && actualWave == EnemyWave.Second)
                {
                    actualWave = EnemyWave.Third;
                    startTime  = (int)deltaTime.TotalGameTime.TotalSeconds + 3;
                    enemySpeed = 2;
                    fireRate   = 190;
                }
                else if (actualScore > 300 && actualWave == EnemyWave.Third)
                {
                    actualWave = EnemyWave.Fourth;
                    startTime  = (int)deltaTime.TotalGameTime.TotalSeconds + 3;
                    enemySpeed = 2;
                    fireRate   = 150;
                }
                else if (actualScore > 400 && actualWave == EnemyWave.Fourth)
                {
                    actualWave = EnemyWave.Fifth;
                    startTime  = (int)deltaTime.TotalGameTime.TotalSeconds + 3;
                    enemySpeed = 2;
                    fireRate   = 120;
                }

                //deleting missiles
                for (int i = 0; i < missiles.Count; i++)
                {
                    if (missiles[i].isDestroyed)
                    {
                        missiles.RemoveAt(i);
                    }
                }

                //deleting enemies
                for (int i = 0; i < enemies.Count; i++)
                {
                    if (enemies[i].isDestroyed)
                    {
                        enemies.RemoveAt(i);
                    }
                }

                //creating missiles
                if (missiles.Count == 0)
                {
                    missiles.Add(new Missile(player.missileTexture, player.location.X, (int)(player.missileSpeed * skillCheck.multiplier)));
                }
                else if (missiles[missiles.Count - 1].isNextReady(fireRate))
                {
                    missiles.Add(new Missile(player.missileTexture, player.location.X, (int)(player.missileSpeed * skillCheck.multiplier)));
                }

                //creating enemies
                if (deltaTime.TotalGameTime.TotalSeconds > startTime)
                {
                    if (enemies.Count == 0)
                    {
                        enemies.Add(new Enemy(enemyTextures, r.Next(4), enemySpeed, actualWave));
                    }
                    else if (enemies[enemies.Count - 1].isNextReady())
                    {
                        enemies.Add(new Enemy(enemyTextures, r.Next(4), enemySpeed, actualWave));
                    }
                }

                if (deltaTime.TotalGameTime.TotalSeconds > nextSkilCheck)
                {
                    skillCheck.Run();
                    nextSkilCheck = r.Next((int)deltaTime.TotalGameTime.TotalSeconds + 20, (int)deltaTime.TotalGameTime.TotalSeconds + 40);
                }

                //updateplayer health
                foreach (Enemy e in enemies)
                {
                    if (e.location.Y >= 2340 && !e.isDestroyed)
                    {
                        e.isDestroyed   = true;
                        heartBlinkLeft += 10;
                        if (player.Hit())
                        {
                            if (actualScore > highScore)
                            {
                                highScore    = actualScore;
                                newHighScore = true;
                                SaveSettings();
                            }
                            else
                            {
                                newHighScore = false;
                            }
                            _gameState = GameState.Menu;
                            _menuState = MenuState.EndOfGame;

                            PlaySong();
                        }
                    }
                }

                //enemy-missile collision handling
                foreach (Missile m in missiles)
                {
                    foreach (Enemy e in enemies)
                    {
                        if (e.location.Contains(new Point(m.location.X + 8, m.location.Y + 135)) && !(e.isDestroyed || m.isDestroyed))
                        {
                            if (e.Hit(skillCheck.damage))
                            {
                                actualScore++;
                                if (actualScore % 5 == 0)
                                {
                                    enemySpeed++;
                                }
                            }
                            m.isDestroyed = true;
                        }
                    }
                }

                //hearts blinking
                if (heartBlinkLeft > 0)
                {
                    if (deltaTime.TotalGameTime.TotalMilliseconds >= nextBlinkTime)
                    {
                        player.heartVisible = !player.heartVisible;

                        nextBlinkTime = deltaTime.TotalGameTime.TotalMilliseconds + 100;
                        heartBlinkLeft--;
                    }
                }

                if (skillCheck.isActive)
                {
                    //updating enemies, missiles and background position
                    foreach (Enemy e in enemies)
                    {
                        e.UpdateSlow();
                    }
                    foreach (Missile m in missiles)
                    {
                        m.UpdateSlow();
                    }
                    gameplayBackground.UpdateSlow();
                    skillCheck.Update(deltaTime);

                    if (!skillCheck.isPressed)
                    {
                        touchCollection = TouchPanel.GetState();
                        foreach (TouchLocation tl in touchCollection)
                        {
                            if (tl.State == TouchLocationState.Pressed)
                            {
                                skillCheck.Press(deltaTime);
                            }
                        }
                    }
                }
                else
                {
                    //updating enemies, missiles and background position
                    foreach (Enemy e in enemies)
                    {
                        e.Update();
                    }
                    foreach (Missile m in missiles)
                    {
                        m.Update();
                    }
                    gameplayBackground.Update();

                    //controls / touch handling
                    touchCollection = TouchPanel.GetState();

                    foreach (TouchLocation tl in touchCollection)
                    {
                        Vector2 position      = new Vector2((int)tl.Position.X, (int)tl.Position.Y);
                        Vector2 touchPosition = Vector2.Transform(position, Matrix.Invert(matrix));

                        if (pauseButton.isPressed)
                        {
                            if (tl.State == TouchLocationState.Released && pauseButton.location.Contains(touchPosition))
                            {
                                pauseButton.unpress();
                                _gameplayState = GameplayState.Paused;
                            }
                            else if (tl.State == TouchLocationState.Released)
                            {
                                pauseButton.unpress();
                            }
                        }
                        else
                        {
                            if (pauseButton.location.Contains(touchPosition) && tl.State == TouchLocationState.Pressed)
                            {
                                pauseButton.press();
                            }
                            else
                            {
                                //player ship controls
                                if (touchPosition.X < 150)
                                {
                                    player.location.X = 0;
                                }
                                else if (touchPosition.X > 930)
                                {
                                    player.location.X = 780;
                                }
                                else
                                {
                                    player.location.X = (int)touchPosition.X - 150;
                                }
                            }
                        }
                    }

                    //pressing Android back button
                    if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                    {
                        _gameplayState = GameplayState.Paused;
                    }
                }
            }
            //game paused
            else if (_gameplayState == GameplayState.Paused)
            {
                touchCollection = TouchPanel.GetState();

                foreach (TouchLocation tl in touchCollection)
                {
                    Vector2 position      = new Vector2((int)tl.Position.X, (int)tl.Position.Y);
                    Vector2 touchPosition = Vector2.Transform(position, Matrix.Invert(matrix));

                    foreach (Button b in pauseMenuButtons)
                    {
                        if (b.isPressed)
                        {
                            if (tl.State == TouchLocationState.Released && b.location.Contains(touchPosition))
                            {
                                switch (b.Name)
                                {
                                case "resume":
                                    b.unpress();
                                    _gameplayState = GameplayState.Unpaused;
                                    break;

                                case "exit":
                                    b.unpress();
                                    _gameState = GameState.Menu;
                                    PlaySong();
                                    break;
                                }
                            }
                            else if (tl.State == TouchLocationState.Released)
                            {
                                b.unpress();
                            }
                        }
                        else
                        {
                            if (b.location.Contains(touchPosition) && tl.State == TouchLocationState.Pressed)
                            {
                                b.press();
                            }
                        }
                    }
                }
            }
        }