static void Main(string[] args) { Console.CursorVisible = false; Thread thread = new Thread(Game); Thread thread1 = new Thread(Game1); thread.Start(); thread1.Start(); while (!gameOver) { ConsoleKeyInfo keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.UpArrow && check != 1) { direction = 1; check = 2; } if (keyInfo.Key == ConsoleKey.DownArrow && check != 2) { direction = 2; check = 1; } if (keyInfo.Key == ConsoleKey.RightArrow && check != 3) { direction = 3; check = 4; } if (keyInfo.Key == ConsoleKey.LeftArrow && check != 4) { direction = 4; check = 3; } if (keyInfo.Key == ConsoleKey.W && check != 1) { direction1 = 1; check = 2; } if (keyInfo.Key == ConsoleKey.S && check != 2) { direction1 = 2; check = 1; } if (keyInfo.Key == ConsoleKey.D && check != 3) { direction1 = 3; check = 4; } if (keyInfo.Key == ConsoleKey.A && check != 4) { direction1 = 4; check = 3; } if (keyInfo.Key == ConsoleKey.Escape) { gameOver = true; } if (keyInfo.Key == ConsoleKey.R) { snake = new Snake(); } if (keyInfo.Key == ConsoleKey.S) { snake.Serialization(); wall.Serialization(); fruit.Serialization(); GameFilesS(); } if (keyInfo.Key == ConsoleKey.L) { snake = snake.Deserialization(); wall = wall.Deserialization(); fruit = fruit.Deserialization(); GameFilesD(speed, level, score, cnt); } } }