port back to 1x64x64 matrix

This commit is contained in:
Baipyrus 2023-04-19 15:05:35 +02:00
parent 7baabd7cc3
commit 17ff309a01
3 changed files with 22 additions and 20 deletions

View File

@ -32,7 +32,7 @@ namespace Tetris {
private static Player player = new(), next = new(true);
public static bool selection, ptbLogo = true;
public static int selectionIndex, frameCount;
public static int sw = 9, sh = 9;
public static int sw = 3, sh = 3;
private static int score, bounds;
// Matrix variables
@ -55,9 +55,12 @@ namespace Tetris {
} else {
matrix = new(
new RGBLedMatrixOptions {
HardwareMapping = "adafruit-hat",
LimitRefreshRateHz = 0,
GpioSlowdown = 5,
ChainLength = 3,
Parallel = 3,
ChainLength = 1,
Parallel = 1,
ScanMode = 1,
Rows = 64,
Cols = 64,
});
@ -67,7 +70,7 @@ namespace Tetris {
Stopwatch stopwatch = new();
// Initialize Console Color and Text-Font and -Color
RGBLedFont font = new("fonts/9x18B.bdf");
RGBLedFont font = new("fonts/5x8.bdf");
Console.ForegroundColor = ConsoleColor.White;
Color col = new(255, 255, 255), grey = new(127, 127, 127);
@ -130,33 +133,32 @@ namespace Tetris {
}
// Draw line "in the middle"
for (int i = 0; i < 192; i++)
for (int i = 0; i < 64; i++)
canvas.SetPixel(sw*10, i, grey);
// Statically display stored item on the right side
canvas.DrawText(font, 92, 18, col, "Save:");
canvas.DrawText(font, 33, 8, col, "Save:");
if (player.memDis != null && player.memCol != null)
foreach (int[] b in player.memDis)
for (int k = 0; k < sw; k++)
for (int l = 0; l < sh; l++)
canvas.SetPixel(96 + b[0] * sw + k, 36 + b[1] * sh + l, (Color)player.memCol);
canvas.SetPixel(34 + b[0] * sw + k, 13 + b[1] * sh + l, (Color)player.memCol);
// Statically display next item below the previous
canvas.DrawText(font, 92, 90, col, "Next:");
canvas.DrawText(font, 33, 30, col, "Next:");
if (next.memDis != null)
foreach (int[] b in next.memDis)
for (int k = 0; k < sw; k++)
for (int l = 0; l < sh; l++)
canvas.SetPixel(96 + b[0] * sw + k, 108 + b[1] * sh + l, next.color);
canvas.SetPixel(34 + b[0] * sw + k, 35 + b[1] * sh + l, next.color);
// Fill bottom
for (int i = 1; i <= sh/3; i++)
for (int j = 0; j < sw*10; j++)
canvas.SetPixel(j, 192-i, grey);
for (int j = 0; j < sw*10; j++)
canvas.SetPixel(j, 63, grey);
// Display score
canvas.DrawText(font, 92, 162, col, $"Score:");
canvas.DrawText(font, 92, 180, col, score.ToString());
canvas.DrawText(font, 33, 52, col, $"Score:");
canvas.DrawText(font, 33, 60, col, score.ToString());
// Move Player down every few frames
if (frameCount % 30 == 0 && collisionCheck(player.x, ++player.y, player.positions)) {
@ -182,12 +184,12 @@ namespace Tetris {
while (selection) {
// Display Options and Cursor on Matrix
canvas.Clear();
canvas.DrawText(font, 0, 18, col, "Game Over!");
canvas.DrawText(font, 0, 54, col, " ) Weiter");
canvas.DrawText(font, 0, 72, col, " ) Beenden");
canvas.DrawText(font, 0, 108, col, $"Score: {score}");
canvas.DrawText(font, 0, 8, col, "Game Over!");
canvas.DrawText(font, 0, 24, col, " ) Weiter");
canvas.DrawText(font, 0, 32, col, " ) Beenden");
canvas.DrawText(font, 0, 48, col, $"Score: {score}");
// Cursor is a '#' at (0, 24 + i * 8) where i may be [0, 1]
canvas.DrawText(font, 0, 54+selectionIndex*18, col, "#");
canvas.DrawText(font, 0, 24+selectionIndex*8, col, "#");
canvas = matrix.SwapOnVsync(canvas);
// Handle key presses for continue game or exit

View File

@ -9,7 +9,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>linux-arm64</RuntimeIdentifier>
<RuntimeIdentifier>linux-arm</RuntimeIdentifier>
<PublishReadyToRun>true</PublishReadyToRun>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
</PropertyGroup>

Binary file not shown.