diff --git a/RPI_Matrix.cs b/RPI-Matrix.cs similarity index 85% rename from RPI_Matrix.cs rename to RPI-Matrix.cs index 937e844..08c7888 100644 --- a/RPI_Matrix.cs +++ b/RPI-Matrix.cs @@ -9,9 +9,9 @@ namespace RPI_Matrix { private static int debugIndex; private static bool debugMenu, debugSelect; private static bool hasSelected, isInGame, isTetris, isFlappy, isSnake; + private static bool selection = true, focusHeight, focusGravity, focusJump, isFocused; private static int selectionIndex, keypressFrame, frameCount; - private static bool selection = true; - + public static void Main() { // Connect to RGB LED Matrix RGBLedMatrix matrix = new( @@ -53,7 +53,7 @@ namespace RPI_Matrix { 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, " ) Debug"); + canvas.DrawText(font, 0, 56, col, " ) Einstell."); canvas.DrawText(font, 0, 64, 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); @@ -141,11 +141,20 @@ namespace RPI_Matrix { while (debugMenu) { // Display Games and Cursor on Matrix canvas.Clear(); - canvas.DrawText(font, 0, 8, col, $" ) PTB Logo {(Tetris.Tetris.ptbLogo ? "I" : "O")}"); - canvas.DrawText(font, 0, 24, col, " ) Zurück"); + 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"); + // Cursor is a '#' at (0, 24 + i * 8) where i may be [0, 2] - int nx = debugIndex + ((debugIndex == 1) ? 1 : 0); - canvas.DrawText(font, 0, 8 + nx * 8, col, "#"); + int nx = debugIndex; + if (debugIndex >= 1) nx++; + if (debugIndex >= 4) nx++; + + canvas.DrawText(font, 0, 16 + nx * 8, col, "#"); canvas = matrix.SwapOnVsync(canvas); // Handle key presses for selecting a game @@ -176,6 +185,21 @@ namespace RPI_Matrix { Tetris.Tetris.ptbLogo = !Tetris.Tetris.ptbLogo; break; case 1: + // Focus Height to be changed with arrow keys + focusHeight = true; + isFocused = true; + break; + case 2: + // Focus Gravity to be changed with arrow keys + focusGravity = true; + isFocused = true; + break; + case 3: + // Focus Jump to be changed with arrow keys + focusJump = true; + isFocused = true; + break; + case 4: // Go back to menu debugMenu = false; break; @@ -263,6 +287,12 @@ namespace RPI_Matrix { // Place the current Block in Tetris } else if (isTetris) Tetris.Tetris.placeDownBlock(); + else if (!isSnake) { + focusGravity = false; + focusHeight = false; + focusJump = false; + isFocused = false; + } break; case "01-00-01-04": // Code for L-Button Press @@ -312,7 +342,13 @@ namespace RPI_Matrix { else if (isFlappy && FlappyBird.FlappyBird.selection && FlappyBird.FlappyBird.selectionIndex > 0) FlappyBird.FlappyBird.selectionIndex--; - else if (debugIndex > 0) + else if (focusGravity) + FlappyBird.FlappyBird.gravity += 0.01f; + else if (focusHeight && FlappyBird.FlappyBird.spaceHeight < 58) + FlappyBird.FlappyBird.spaceHeight += 1; + else if (focusJump) + FlappyBird.FlappyBird.jumpVel += 0.01f; + else if (debugIndex > 0 && !isFocused) debugIndex--; break; case "FF-7F-02-01": @@ -338,7 +374,13 @@ namespace RPI_Matrix { Tetris.Tetris.moveDownOnce(); else if (isFlappy && FlappyBird.FlappyBird.selection && FlappyBird.FlappyBird.selectionIndex < 1) FlappyBird.FlappyBird.selectionIndex++; - else if (debugIndex < 1) + else if (focusGravity && FlappyBird.FlappyBird.gravity > 0) + FlappyBird.FlappyBird.gravity -= 0.01f; + else if (focusHeight && FlappyBird.FlappyBird.spaceHeight > 2) + FlappyBird.FlappyBird.spaceHeight -= 1; + else if (focusJump && FlappyBird.FlappyBird.jumpVel > 0) + FlappyBird.FlappyBird.jumpVel -= 0.01f; + else if (debugIndex < 4 && !isFocused) debugIndex++; break; case "01-80-02-00": diff --git a/RPI_Matrix.csproj b/RPI-Matrix.csproj similarity index 100% rename from RPI_Matrix.csproj rename to RPI-Matrix.csproj