private void SetPlayerDirection() { if (Input.IsKeyDown(Keys.Left)) { Player1.SetDirection(Direction.Left); } else if (Input.IsKeyDown(Keys.Right)) { Player1.SetDirection(Direction.Right); } else if (Input.IsKeyDown(Keys.Up)) { Player1.SetDirection(Direction.Up); } else if (Input.IsKeyDown(Keys.Down)) { Player1.SetDirection(Direction.Down); } }
private void SetPlayerMovement() { if (Input.IsKeyDown(Keys.A)) { Player1.SetDirection(Direction.left); } else if (Input.IsKeyDown(Keys.D)) { Player1.SetDirection(Direction.right); } else if (Input.IsKeyDown(Keys.W)) { Player1.SetDirection(Direction.up); } else if (Input.IsKeyDown(Keys.S)) { Player1.SetDirection(Direction.down); } Player1.MovePlayer(); }
public void Snake_KeyDown(object sender, KeyEventArgs e) { Keys code = e.KeyCode; if (code == Keys.Left || code == Keys.A) { player.SetDirection(Direction.Left); } else if (code == Keys.Right || code == Keys.D) { player.SetDirection(Direction.Right); } else if (code == Keys.Up || code == Keys.W) { player.SetDirection(Direction.Up); } else if (code == Keys.Down || code == Keys.S) { player.SetDirection(Direction.Down); } }
private void SetPlayerMovement() { if (!controlsSwapped) { if (Input.IsKeyDown(Keys.Left)) { Player1.SetDirection(Direction.left); } else if (Input.IsKeyDown(Keys.Right)) { Player1.SetDirection(Direction.right); } else if (Input.IsKeyDown(Keys.Up)) { Player1.SetDirection(Direction.up); } else if (Input.IsKeyDown(Keys.Down)) { Player1.SetDirection(Direction.down); } } else { if (Input.IsKeyDown(Keys.A)) { Player1.SetDirection(Direction.left); } else if (Input.IsKeyDown(Keys.D)) { Player1.SetDirection(Direction.right); } else if (Input.IsKeyDown(Keys.W)) { Player1.SetDirection(Direction.up); } else if (Input.IsKeyDown(Keys.S)) { Player1.SetDirection(Direction.down); } } if (is2Player) { if (!controlsSwapped) { if (Input.IsKeyDown(Keys.A)) { Player2.SetDirection(Direction.left); } else if (Input.IsKeyDown(Keys.D)) { Player2.SetDirection(Direction.right); } else if (Input.IsKeyDown(Keys.W)) { Player2.SetDirection(Direction.up); } else if (Input.IsKeyDown(Keys.S)) { Player2.SetDirection(Direction.down); } } else { if (Input.IsKeyDown(Keys.Left)) { Player2.SetDirection(Direction.left); } else if (Input.IsKeyDown(Keys.Right)) { Player2.SetDirection(Direction.right); } else if (Input.IsKeyDown(Keys.Up)) { Player2.SetDirection(Direction.up); } else if (Input.IsKeyDown(Keys.Down)) { Player2.SetDirection(Direction.down); } } Player2.MovePlayer(); } Player1.MovePlayer(); }