public void Update(float deltaTime) { parallax.Update(deltaTime); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { switch (gameState) { case GameState.Main: KeyboardState currKeyState = Keyboard.GetState(); menuBackSong.Play(); if (currKeyState.IsKeyDown(Keys.Enter)) { menuBackSong.Stop(); //Stops the background music in the main menu. inGameBackSong.Play(); //Plays the in game music. startSound.Play(); //A sound effect plays telling the game has started. gameState = GameState.InGame; //Switching game states. } else if (currKeyState.IsKeyDown(Keys.H)) { gameState = GameState.How; } break; case GameState.How: KeyboardState KeyState = Keyboard.GetState(); if (KeyState.IsKeyDown(Keys.Escape)) { gameState = GameState.Main; } break; case GameState.InGame: //Update each part of the game. UpdateInput(); UpdateTimer(gameTime); UpdateDifficulty(gameTime); background.Update(gameTime); UpdatePlayer(gameTime); UpdatePlatforms(gameTime); UpdateBullets(gameTime); UpdateAsteroids(gameTime); UpdatePowerDownUps(gameTime); break; case GameState.Lose: KeyboardState currentKeyState = Keyboard.GetState(); if (currentKeyState.IsKeyDown(Keys.Enter)) { Initialize(); //Reset everything to their default values. gameState = GameState.InGame; } break; default: break; } base.Update(gameTime); }