public void playAgainstComputer() { Console.CursorVisible = false; cSnake = new ComputerSnake(snake.PositionX + 5, snake.PositionY + 5); cSnake1 = new ComputerSnake(snake.PositionX + 5, snake.PositionY + 5); cSnake2 = new ComputerSnake(snake.PositionX + 5, snake.PositionY + 5); timer.Elapsed += new ElapsedEventHandler(OnTimedEvent2); timer.Enabled = true; cSnake.size = dimension; cSnake1.size = dimension; cSnake2.size = dimension; //Console.Clear(); board.drawBoard(); Console.CursorVisible = false; apple.generate(); //apple1.generate(); //apple2.generate(); ConsoleKey action = ConsoleKey.UpArrow; snake.draw(); while (action == ConsoleKey.UpArrow || action == ConsoleKey.DownArrow || action == ConsoleKey.LeftArrow || action == ConsoleKey.RightArrow) { action = Console.ReadKey().Key; snake.changeDirection(action); } }
public void Eat(Apple apple) { if (apple.X == PositionX && apple.Y == PositionY) { grow = true; apple.generate(); } }