feat: initial project structure with Snake.Core, CLI and Avalonia skeleton

This commit is contained in:
Heller
2026-06-17 19:02:07 +00:00
commit 42fcaf8631
25 changed files with 661 additions and 0 deletions

44
Snake.CLI/Program.cs Normal file
View File

@@ -0,0 +1,44 @@
using Snake.CLI;
using Snake.Core;
const int boardWidth = 20;
const int boardHeight = 15;
const int tickMs = 120;
SnakeGame game = new(boardWidth, boardHeight);
ConsoleRenderer.Render(game);
while (true)
{
if (Console.KeyAvailable)
{
var key = Console.ReadKey(intercept: true).Key;
switch (key)
{
case ConsoleKey.UpArrow:
game.SetDirection(Direction.Up);
break;
case ConsoleKey.DownArrow:
game.SetDirection(Direction.Down);
break;
case ConsoleKey.LeftArrow:
game.SetDirection(Direction.Left);
break;
case ConsoleKey.RightArrow:
game.SetDirection(Direction.Right);
break;
case ConsoleKey.Q:
return;
case ConsoleKey.R when game.IsGameOver:
game = new SnakeGame(boardWidth, boardHeight);
break;
}
}
if (!game.IsGameOver)
game.Tick();
ConsoleRenderer.Render(game);
Thread.Sleep(tickMs);
}