public void LaunchGame(Game newGame) { Console.SetWindowSize(mapWidth, mapHeight + 6); newGame.GenerateMap(mapHeight, mapWidth, stage); Snake snake = newGame.Map.Snake; builder = new ConsoleMapBuilder(mapWidth, mapHeight); Console.BackgroundColor = ConsoleColor.Cyan; Console.ForegroundColor = ConsoleColor.Yellow; Console.SetCursorPosition(0, mapHeight); for (int i = 0; i < 6; i++) { Console.WriteLine(new string(' ', mapWidth)); } while (true) { if (Console.KeyAvailable) { switch (Console.ReadKey().Key) { case ConsoleKey.DownArrow: snake.ChangeDirection(MovingEntity.TDirection.Down); break; case ConsoleKey.UpArrow: snake.ChangeDirection(MovingEntity.TDirection.Up); break; case ConsoleKey.LeftArrow: snake.ChangeDirection(MovingEntity.TDirection.Left); break; case ConsoleKey.RightArrow: snake.ChangeDirection(MovingEntity.TDirection.Right); break; } } while (!Console.KeyAvailable) { if (newGame.Map.GameOver) { Console.SetCursorPosition(mapWidth / 2 - 10, mapHeight / 2 - 2); Console.ForegroundColor = ConsoleColor.DarkMagenta; Console.BackgroundColor = ConsoleColor.Black; Console.WriteLine(new string(' ', 20)); Console.SetCursorPosition(mapWidth / 2 - 10, mapHeight / 2 - 1); Console.WriteLine(" KONIEC GRY "); Console.SetCursorPosition(mapWidth / 2 - 10, mapHeight / 2); Console.WriteLine(new string(' ', 20)); string wynik = "WYNIK: " + newGame.Map.Snake.Score.ToString(), output = ""; output = new string(' ', (20 - wynik.Length) / 2) + wynik + new string(' ', (20 - wynik.Length) / 2 + (20 - wynik.Length) % 2); Console.SetCursorPosition(mapWidth / 2 - 10, mapHeight / 2 + 1); Console.WriteLine(output); Console.SetCursorPosition(mapWidth / 2 - 10, mapHeight / 2 + 2); Console.WriteLine(new string(' ', 20)); Console.ReadKey(); return; } Console.ForegroundColor = ConsoleColor.Yellow; Console.BackgroundColor = ConsoleColor.DarkMagenta; List <Entity> entities = newGame.Map.Entities; foreach (Entity entity in entities) { if (entity is Fruit) { builder.BuildFruit((Fruit)entity); } if (entity is Powerup) { builder.BuildPowerup((Powerup)entity); } if (entity is Obstacle) { builder.BuildObstacle((Obstacle)entity); } if (entity is Mouse) { builder.BuildMouse((Mouse)entity); } } builder.BuildSnake(snake); foreach (Point position in newGame.Map.ClearedPositions) { System.Diagnostics.Debug.WriteLine(position.ToString()); } builder.ClearMap(newGame.Map.ClearedPositions); Console.SetCursorPosition(2, mapHeight + 1); Console.ForegroundColor = ConsoleColor.Black; Console.BackgroundColor = ConsoleColor.Cyan; Console.Write(new string(' ', mapWidth)); Console.SetCursorPosition(2, mapHeight + 1); Console.Write(newGame.Map.Snake.Score.ToString()); Console.SetCursorPosition(mapWidth - 6, mapHeight + 1); Console.ForegroundColor = ConsoleColor.Red; Console.Write(Convert.ToChar(9829)); Console.ForegroundColor = ConsoleColor.Black; Console.Write(" x " + newGame.Map.Snake.Lives.ToString()); if (newGame.Map.Snake.Effect.Variant != Effect.EffectVariant.None) { Console.SetCursorPosition(0, mapHeight + 3); Console.WriteLine(new string(' ', mapWidth)); if (newGame.Map.Snake.Effect.Duration > 0) { Console.SetCursorPosition(2, mapHeight + 3); Console.Write(newGame.Map.Snake.Effect.ToString()); Console.SetCursorPosition(mapWidth - 6, mapHeight + 3); Console.Write(newGame.Map.Snake.Effect.Duration.ToString()); } } newGame.Map.Update(); Thread.Sleep(wait); } } }