commit 83757d5f7909a9379c71bacc5cc40190aa33cd4e Author: Baipyrus Date: Tue Oct 18 07:49:03 2022 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cb151a6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +bin/* +obj/* +.idea/* +fonts/* +samples/* diff --git a/RGBLedMatrix.dll b/RGBLedMatrix.dll new file mode 100644 index 0000000..f1363ee Binary files /dev/null and b/RGBLedMatrix.dll differ diff --git a/RPI_Matrix.cs b/RPI_Matrix.cs new file mode 100644 index 0000000..ed14371 --- /dev/null +++ b/RPI_Matrix.cs @@ -0,0 +1,78 @@ +using System; +using System.Diagnostics; +using System.Threading; +using SnakeGame; +using FlappyBird; +// using static Tetris.Tetris; +using rpi_rgb_led_matrix_sharp; + + +namespace RPI_Matrix { + class RPI_Matrix { + public static void Main() { + RGBLedMatrix matrix = new( + new RGBLedMatrixOptions { + HardwareMapping = "adafruit-hat", + LimitRefreshRateHz = 0, + GpioSlowdown = 4, + Brightness = 100, + ChainLength = 1, + ScanMode = 1, + Rows = 64, + Cols = 64, + }); + RGBLedCanvas canvas = matrix.CreateOffscreenCanvas(); + RGBLedFont font = new("fonts/5x8.bdf"); + Color col = new(255, 255, 255); + + Console.Clear(); + + bool startover = true; + while (startover) { + canvas.Clear(); + canvas.DrawText(font, 0, 8, col, "Spielauswahl:"); + canvas.DrawText(font, 0, 24, col, "0) Beenden"); + canvas.DrawText(font, 0, 32, col, "1) SnakeGame"); + canvas.DrawText(font, 0, 40, col, "2) FlappyBird"); + canvas.DrawText(font, 0, 48, col, "3) Tetris"); + matrix.SwapOnVsync(canvas); + + bool selection = true; + int frameCount = 0, keypressFrame = 0; + while (selection) { + // Handle key presses for selecting a game + if (Console.KeyAvailable) { + keypressFrame = frameCount; + switch (Console.ReadKey(true).Key) { + case ConsoleKey.D0: + selection = false; + startover = false; + break; + case ConsoleKey.D1: + selection = false; + SnakeGame.SnakeGame.Main(new[] { "-s" }, matrix, canvas); + break; + case ConsoleKey.D2: + selection = false; + FlappyBird.FlappyBird.Main(matrix, canvas); + break; + case ConsoleKey.D3: + selection = false; + // Tetris.Tetris.Main(matrix, canvas); + break; + } + } + + if (frameCount >= keypressFrame + 150) { + selection = false; + keypressFrame = frameCount; + SnakeGame.SnakeGame.Main(new[] { "-b" }, matrix, canvas); + } + + Thread.Sleep(100); + frameCount = (frameCount+1)%1000000; + } + } + } + } +} \ No newline at end of file diff --git a/RPI_Matrix.csproj b/RPI_Matrix.csproj new file mode 100644 index 0000000..230e04f --- /dev/null +++ b/RPI_Matrix.csproj @@ -0,0 +1,33 @@ + + + + + + + + + + + + Exe + enable + true + net6.0 + true + linux-arm64 + true + + + + + + + + + + + + + + + diff --git a/librgbmatrix.so b/librgbmatrix.so new file mode 100644 index 0000000..d0134a6 Binary files /dev/null and b/librgbmatrix.so differ