initial commit
This commit is contained in:
commit
83757d5f79
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
bin/*
|
||||||
|
obj/*
|
||||||
|
.idea/*
|
||||||
|
fonts/*
|
||||||
|
samples/*
|
BIN
RGBLedMatrix.dll
Normal file
BIN
RGBLedMatrix.dll
Normal file
Binary file not shown.
78
RPI_Matrix.cs
Normal file
78
RPI_Matrix.cs
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
RPI_Matrix.csproj
Normal file
33
RPI_Matrix.csproj
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<!-- Reference to local copy of https://gitlab1.ptb.de/waltem01/csharpsocketserver -->
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\RPI-Snake\SnakeGame.csproj" />
|
||||||
|
<ProjectReference Include="..\RPI-Flappy\FlappyBird.csproj" />
|
||||||
|
<ProjectReference Include="..\SocketTest\Net.Sockets\SocketLib.csproj" />
|
||||||
|
<Reference Include="RGBLedMatrix.dll" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<SelfContained>true</SelfContained>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<PublishReadyToRun>true</PublishReadyToRun>
|
||||||
|
<RuntimeIdentifier>linux-arm64</RuntimeIdentifier>
|
||||||
|
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Remove="samples\**" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Remove="samples\**" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="samples\**" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
BIN
librgbmatrix.so
Normal file
BIN
librgbmatrix.so
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user