private void DoGameLoop() { if (_isAutomatedControlled) { OnSnakeMove?.Invoke(Player1); } else { SetPlayerDirection(); } Player1.MovePlayer(); CheckForCollisions(); GameCanvas.Invalidate(); }
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(); }
private void SetPlayerMovement() { //if (Input.IsKeyDown(Keys.Left) || Input.IsKeyDown(Keys.A)) //{ // player.SetDirection(Direction.Left); //} //else if (Input.IsKeyDown(Keys.Right) || Input.IsKeyDown(Keys.D)) //{ // player.SetDirection(Direction.Right); //} //else if (Input.IsKeyDown(Keys.Up) || Input.IsKeyDown(Keys.W)) //{ // player.SetDirection(Direction.Up); //} //else if (Input.IsKeyDown(Keys.Down) || Input.IsKeyDown(Keys.S)) //{ // player.SetDirection(Direction.Down); //} player.MovePlayer(); }
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(); }