/// <summary> /// Checks whether the a certain key on the keyboard was pressed during last update. /// </summary> /// <param name="name">The name of the key to check for.</param> /// <param name="helper">The InputHelper to use for keyboard input.</param> /// <returns>True if the specified key was pressed, false otherwise.</returns> /// <exception cref="ArgumentException">When the specified name is not found.</exception> public bool KeyPressed(string name, InputHelper helper) { // Make sure the name supplied is registered if (!keysByName.ContainsKey(name)) { throw new ArgumentException("Key '" + name + "' was not registered but was requested."); } // Return whether the specified key was pressed this update. return(helper.KeyPressed(keysByName[name])); }
/// <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 (!running) { Exit(); } inputHelper.Update(gameTime); camera.Update(gameTime, inputHelper, KeyManager.Instance); // Update current gamestate GameStateManager.Update(gameTime); GameStateManager.HandleInput(inputHelper, KeyManager.Instance); //TIJDELIJKE CODE OMDAT IK GEEN IDEE HEB WAAR IK DIT ANDERS ZOU KUNNEN ZETTEN if (inputHelper.KeyPressed(Keys.Escape)) { ToggleFullScreen(); } //EINDE TIJDELIJKE CODE base.Update(gameTime); }