public override void OnInput(GameTime gt, GameInput input) { int moveSpeed = 3; if (isInputEnabled == false) { return; } if (input.IsKeyDown(Keys.Up)) { if (isOutOfBounds(Bounds.Top) == false) { commanderSprite.Position.Y -= moveSpeed; } } if (input.IsKeyDown(Keys.Down)) { if (isOutOfBounds(Bounds.Bottom) == false) { commanderSprite.Position.Y += moveSpeed; } } if (input.IsKeyDown(Keys.Left)) { if (isOutOfBounds(Bounds.Left) == false) { commanderSprite.Position.X -= moveSpeed; } } if (input.IsKeyDown(Keys.Right)) { if (isOutOfBounds(Bounds.Right) == false) { commanderSprite.Position.X += moveSpeed; } } if (input.IsKeyDown(Keys.Space)) { Fire(gt); } }
public void Update(GameTime gameTime, GameInput input) { if (isPaused == true) { if (input.IsKeyPress(Keys.P)) { isPaused = !isPaused; } else { return; } } else { if (input.IsKeyPress(Keys.P)) { isPaused = true; return; } } while (removeQueue.Count > 0) { Tuple <int, GameObject> tup = removeQueue.Dequeue(); GameObjects.Remove(tup.Item1); } while (addQueue.Count > 0) { Tuple <int, GameObject> tup = addQueue.Dequeue(); GameObjects.Add(tup.Item1, tup.Item2); } if (isAlienVictorious == false) { collider.CheckCollisions(); alienBag.CheckEdgeCollision(); } foreach (GameObject obj in GameObjects.Values) { obj.OnInput(gameTime, input); obj.Update(gameTime); } if (input.IsKeyDown(Keys.K)) { isAlienVictorious = true; commander.Kill(); } collider.RemoveQueuedItems(); }