feat: fully functional CLI and Avalonia UI for Snake game
This commit is contained in:
@@ -7,7 +7,7 @@ internal static class ConsoleRenderer
|
||||
public static void Render(SnakeGame game)
|
||||
{
|
||||
Console.Clear();
|
||||
Console.WriteLine($"Score: {game.Score}");
|
||||
Console.WriteLine($"Score: {game.Score} Level: {game.Level}");
|
||||
|
||||
if (game.IsGameOver)
|
||||
Console.WriteLine("Game Over! Press R to restart or Q to quit.");
|
||||
|
||||
@@ -3,7 +3,7 @@ using Snake.Core;
|
||||
|
||||
const int boardWidth = 20;
|
||||
const int boardHeight = 15;
|
||||
const int tickMs = 120;
|
||||
const int baseTickMs = 120;
|
||||
|
||||
SnakeGame game = new(boardWidth, boardHeight);
|
||||
ConsoleRenderer.Render(game);
|
||||
@@ -40,5 +40,5 @@ while (true)
|
||||
game.Tick();
|
||||
|
||||
ConsoleRenderer.Render(game);
|
||||
Thread.Sleep(tickMs);
|
||||
Thread.Sleep(SnakeGame.GetTickIntervalMs(game.Score, baseTickMs));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user