private void UpdateScreen(object sender, EventArgs e) { //Check if Game Over if (GameSettings.Gameover) { //Check if enter key is pressed if (KeyboardInput.KeyPressed(Keys.Enter)) { StartGame(); } } else { if (KeyboardInput.KeyPressed(Keys.Right) && GameSettings.Directions != Direction.Left) { GameSettings.Directions = Direction.Right; } else if (KeyboardInput.KeyPressed(Keys.Left) && GameSettings.Directions != Direction.Right) { GameSettings.Directions = Direction.Left; } else if (KeyboardInput.KeyPressed(Keys.Up) && GameSettings.Directions != Direction.Down) { GameSettings.Directions = Direction.Up; } else if (KeyboardInput.KeyPressed(Keys.Down) && GameSettings.Directions != Direction.Up) { GameSettings.Directions = Direction.Down; } MovePlayer(); } pbCanvas.Invalidate(); }
private void Form1_KeyUp(object sender, KeyEventArgs e) { KeyboardInput.ChangeState(e.KeyCode, false); }
private void Form1_KeyDown(object sender, KeyEventArgs e) { KeyboardInput.ChangeState(e.KeyCode, true); }