clean up and expansion

This commit is contained in:
Baipyrus 2022-11-30 08:37:00 +01:00
parent d87dda0068
commit 3a9992befd

View File

@ -12,16 +12,13 @@ namespace RPI_Matrix {
private static bool selection = true, focusHeight, focusGravity, focusJump, isFocused;
private static int selectionIndex, keypressFrame, frameCount;
public static void Main() {
public static void Main(string[] args) {
// Connect to RGB LED Matrix
RGBLedMatrix matrix = new(
new RGBLedMatrixOptions {
HardwareMapping = "adafruit-hat",
LimitRefreshRateHz = 0,
GpioSlowdown = 4,
Brightness = 100,
ChainLength = 1,
ScanMode = 1,
GpioSlowdown = 5,
ChainLength = 3,
Parallel = 3,
Rows = 64,
Cols = 64,
});
@ -36,7 +33,7 @@ namespace RPI_Matrix {
(new Thread(InterpretGamepadInput)).Start();
// Initialize Text-Font and -Color
RGBLedFont font = new("fonts/5x8.bdf");
RGBLedFont font = new("fonts/9x18B.bdf");
Color col = new(255, 255, 255);
// Game Menu
@ -49,15 +46,15 @@ namespace RPI_Matrix {
while (selection) {
// Display Games and Cursor on Matrix
canvas.Clear();
canvas.DrawText(font, 0, 8, col, "Spielauswahl:");
canvas.DrawText(font, 0, 24, col, " ) SnakeGame");
canvas.DrawText(font, 0, 32, col, " ) FlappyBird");
canvas.DrawText(font, 0, 40, col, " ) Tetris");
canvas.DrawText(font, 0, 56, col, " ) Einstell.");
canvas.DrawText(font, 0, 64, col, " ) Beenden");
canvas.DrawText(font, 0, 18, col, "Spielauswahl:");
canvas.DrawText(font, 0, 54, col, " ) SnakeGame");
canvas.DrawText(font, 0, 72, col, " ) FlappyBird");
canvas.DrawText(font, 0, 90, col, " ) Tetris");
canvas.DrawText(font, 0, 126, col, " ) Einstell.");
canvas.DrawText(font, 0, 144, col, " ) Beenden");
// Cursor is a '#' at (0, 24 + i * 8) where i may be [0, 1, 2, 3, 5]
int nx = selectionIndex + ((selectionIndex >= 3) ? 1 : 0);
canvas.DrawText(font, 0, 24 + nx * 8, col, "#");
canvas.DrawText(font, 0, 54 + nx * 18, col, "#");
canvas = matrix.SwapOnVsync(canvas);
// Handle key presses for selecting a game
@ -133,7 +130,7 @@ namespace RPI_Matrix {
selection = false;
// Initialize Text-Font and -Color
RGBLedFont font = new("fonts/5x8.bdf");
RGBLedFont font = new("fonts/9x18B.bdf");
Color col = new(255, 255, 255);
// Game selection Menu
@ -141,20 +138,20 @@ namespace RPI_Matrix {
while (debugMenu) {
// Display Games and Cursor on Matrix
canvas.Clear();
canvas.DrawText(font, 0, 8, col, "Tetris:");
canvas.DrawText(font, 0, 16, col, $" ) PTB Logo {(Tetris.Tetris.ptbLogo ? "I" : "O")}");
canvas.DrawText(font, 0, 24, col, "FlappyBird:");
canvas.DrawText(font, 0, 32, col, $" ) Höhe {FlappyBird.FlappyBird.spaceHeight}");
canvas.DrawText(font, 0, 40, col, $" ) Grav. {FlappyBird.FlappyBird.gravity}");
canvas.DrawText(font, 0, 48, col, $" ) Spr. {FlappyBird.FlappyBird.jumpVel}");
canvas.DrawText(font, 0, 64, col, " ) Zurück");
canvas.DrawText(font, 0, 18, col, "Tetris:");
canvas.DrawText(font, 0, 36, col, $" ) PTB Logo {(Tetris.Tetris.ptbLogo ? "I" : "O")}");
canvas.DrawText(font, 0, 54, col, "FlappyBird:");
canvas.DrawText(font, 0, 72, col, $" ) Höhe {FlappyBird.FlappyBird.spaceHeight}");
canvas.DrawText(font, 0, 90, col, $" ) Gravitation {FlappyBird.FlappyBird.gravity}");
canvas.DrawText(font, 0, 108, col, $" ) Sprung Ges. {FlappyBird.FlappyBird.jumpVel}");
canvas.DrawText(font, 0, 144, col, " ) Zurück");
// Cursor is a '#' at (0, 24 + i * 8) where i may be [0, 2]
int nx = debugIndex;
if (debugIndex >= 1) nx++;
if (debugIndex >= 4) nx++;
canvas.DrawText(font, 0, 16 + nx * 8, col, "#");
canvas.DrawText(font, 0, 36 + nx * 18, col, "#");
canvas = matrix.SwapOnVsync(canvas);
// Handle key presses for selecting a game