/// <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) { if (Fade.ShowingFade) { Fade.Update(gameTime); } else { //////////////////////////////////////////////// //HANDLE INPUT //////////////////////////////////////////////// currentTouchCollection = TouchPanel.GetState(); if (CurrentScreen == Screen.Gameplay) { GamePlayScreen.HandleInput(previousTouchCollection, currentTouchCollection, gameTime); } previousTouchCollection = currentTouchCollection; //////////////////////////////////////////////// //UPDATES //////////////////////////////////////////////// if (CurrentScreen == Screen.Gameplay) { currentBackground.Update(gameTime); GamePlayScreen.Update(gameTime); } } base.Update(gameTime); }
public void Update(GameTime gameTime) { background.Update(); enemies.ForEach(e => e.Update(gameTime)); portals.ForEach(p => p.Update(gameTime)); CollisionBoxes = new List <ICollision>(); CollisionBoxes.AddRange(StaticCollisionBoxes); enemies.ForEach(e => CollisionBoxes.Add(e)); portals.ForEach(p => CollisionBoxes.Add(p)); foreach (KeyValuePair <Tuple <int, int>, ICollision> keyValuePair in DynamicCollisionBoxes) { CollisionBoxes.Add(keyValuePair.Value); } }
protected override void Update(GameTime gameTime) { previousKB = currentKB; KeyboardState State = Keyboard.GetState(); currentKB = State; if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || State.IsKeyDown(Keys.Escape)) { Exit(); } if (currentKB.IsKeyUp(Keys.P) && previousKB.IsKeyDown(Keys.P)) { gamePaused = !gamePaused; } if (gamePaused) { return; } if (GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed || State.IsKeyDown(Keys.Space)) { projectileGenerator.FireProjectile(shipSprite.CurrentPos, gameTime); } shipSprite.Update(State); background.Update(); background2.Update(); obstacleGenerator.Update(gameTime); projectileGenerator.Update(gameTime); projectileCollisionTracker.getObjectCoords(projectileGenerator.ActiveProjectiles, obstacleGenerator.AllObstacles); projectileCollisionTracker.CheckUpdateCoords(); fails = Obstacle.failedObjects; base.Update(gameTime); }