private void Form1_KeyDown(object sender, KeyEventArgs e) { if (_keysMap.TryGetValue(e.KeyCode, out var direction)) { _game.ChangeDirection(direction); } }
public async void CheckForKeyPress() { if (IsKeyDown(Keys.Left)) { await _game.ChangeDirection(Direction.Left); } else if (IsKeyDown(Keys.Right)) { await _game.ChangeDirection(Direction.Right); } else if (IsKeyDown(Keys.Up)) { await _game.ChangeDirection(Direction.Up); } else if (IsKeyDown(Keys.Down)) { await _game.ChangeDirection(Direction.Down); } }
public async void RequestNextMoveFromBot() { if (_game.Status == GameStatus.Alive) { var nextDirection = NextMove(); if (nextDirection is object) { await _game.ChangeDirection(nextDirection.Value); } } }
public async void CheckForKeyPress() { if (_game.Status == GameStatus.AttractMode && IsKeyDown(Keys.Space)) { await _game.PressStart(); } else if (IsKeyDown(Keys.Left)) { await _game.ChangeDirection(Direction.Left); } else if (IsKeyDown(Keys.Right)) { await _game.ChangeDirection(Direction.Right); } else if (IsKeyDown(Keys.Up)) { await _game.ChangeDirection(Direction.Up); } else if (IsKeyDown(Keys.Down)) { await _game.ChangeDirection(Direction.Down); } }