public override void Update(GameTime gameTime) { if (MainContent == null) { Screens.Pop(); return; } NewKeyboardState = Keyboard.GetState(); int direction = 0; /* * Right: 1 * Up: 2 * Left: 4 * Down: 8*/ // MOVE PLAYER // We can use the Direction class that I made to avoid confusion if (Keyboard.GetState().IsKeyDown(Keys.Right)) { direction += 1; } if (Keyboard.GetState().IsKeyDown(Keys.Up)) { direction += 2; } if (Keyboard.GetState().IsKeyDown(Keys.Left)) { direction += 4; } if (Keyboard.GetState().IsKeyDown(Keys.Down)) { direction += 8; } if (OldKeyboardState.IsKeyUp(Keys.B) && Keyboard.GetState().IsKeyDown(Keys.B)) { if (MainContent.PlayerShip.getBombs() > 0) { MainContent.PlayerShip.useBomb(); RemoveAllBullets(); } } if (direction != 0) { MainContent.PlayerShip.Move(Direction.ConvertKeyDirection(direction)); } // TOGGLE SPEED // we have to check the key is down, and not just being spammed if (OldKeyboardState.IsKeyUp(Keys.LeftShift) && NewKeyboardState.IsKeyDown(Keys.LeftShift)) { MainContent.PlayerShip.ToggleRate(2); } // fire a bullet if (OldKeyboardState.IsKeyUp(Keys.Space) && NewKeyboardState.IsKeyDown(Keys.Space)) { MainContent.FiringController.From(MainContent.PlayerShip).Between(MainContent.Events.TimeElapsed(), MainContent.Events.TimeElapsed() + .1).Pattern(new SingleBulletFiringPattern()); Stats.BulletFired(); } if (OldKeyboardState.IsKeyUp(Keys.Escape) && NewKeyboardState.IsKeyDown(Keys.Escape)) { Screens.Pop(); Screens.Peek().OldKeyboardState = this.NewKeyboardState; } if (OldKeyboardState.IsKeyUp(Keys.Q) && NewKeyboardState.IsKeyDown(Keys.Q)) { MainContent.ManualInvincibility(); } foreach (BulletModel gb in MainContent.GoodBulletList) { gb.Move(Direction.Stay, Direction.Up); } // update the keyboard state OldKeyboardState = NewKeyboardState; MainContent.Events.ExecuteScheduledEvents(); }