/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { title_screen = new TitleScreen(graphics.GraphicsDevice); controls_screen = new ControlsScreen(); reset = true; game_overseer = new GameOverseer(0, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height, Content, graphics.GraphicsDevice.Viewport); gameover_screen = new GameOverScreen(); base.Initialize(); }
/// <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) { MouseState mouse = Mouse.GetState(); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } // TODO: Add your update logic heres switch (current_game_state) { case GameState.MainMenu: title_screen.update(gameTime); break; case GameState.Controls: controls_screen.update(gameTime); break; case GameState.Playing: Constant.checkPauseKey(Keyboard.GetState(), GamePad.GetState(PlayerIndex.One)); if (!Constant.paused) { game_overseer.update(gameTime, graphics.GraphicsDevice, spriteBatch); } else { GamePad.SetVibration(PlayerIndex.One, 0f, 0f); } break; case GameState.GameOver: if (reset) { game_overseer = new GameOverseer(0, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height, Content, graphics.GraphicsDevice.Viewport); reset = false; } gameover_screen.update(gameTime); break; } //Start music no matter what if (!Constant.background_music_started) { Constant.background_music_started = true; MediaPlayer.IsRepeating = true; MediaPlayer.Play(Constant.background_music); } base.Update(gameTime); }