private void UpdateScreen(object sender, EventArgs e) { //Check for Game Over if (GameSettings.GameOver) { //Check if Enter key is pressed if (ControlsInput.KeyPressed(Keys.Enter)) { StartGame(); } } else { if (ControlsInput.KeyPressed(Keys.Right) && GameSettings.direction != Direction.Left) { GameSettings.direction = Direction.Right; } else if (ControlsInput.KeyPressed(Keys.Left) && GameSettings.direction != Direction.Right) { GameSettings.direction = Direction.Left; } else if (ControlsInput.KeyPressed(Keys.Up) && GameSettings.direction != Direction.Down) { GameSettings.direction = Direction.Up; } else if (ControlsInput.KeyPressed(Keys.Down) && GameSettings.direction != Direction.Up) { GameSettings.direction = Direction.Down; } MovePlayer(); } GameWorld.Invalidate(); }
private void Form1_KeyUp(object sender, KeyEventArgs e) { ControlsInput.ChangeState(e.KeyCode, false); }