debug menu and optional PTB-Logo
This commit is contained in:
parent
5411af3153
commit
37394716ce
83
Tetris.cs
83
Tetris.cs
|
@ -30,9 +30,9 @@ namespace Tetris {
|
|||
private static readonly Color black = new(0, 0, 0);
|
||||
private static bool canSwap = true, gameOver, startOver = true, hasStarted;
|
||||
private static Player player = new(), next = new(true);
|
||||
public static bool selection, ptbLogo = true;
|
||||
public static int selectionIndex, frameCount;
|
||||
private static int score, bounds;
|
||||
public static bool selection;
|
||||
|
||||
// Matrix variables
|
||||
private static RGBLedMatrix? _matrix;
|
||||
|
@ -45,12 +45,6 @@ namespace Tetris {
|
|||
}
|
||||
|
||||
public static void Main() {
|
||||
// Initialize board
|
||||
if (!hasStarted) {
|
||||
initBoard();
|
||||
hasStarted = true;
|
||||
}
|
||||
|
||||
// Initialize RGBLedMatrix
|
||||
RGBLedMatrix matrix;
|
||||
RGBLedCanvas canvas;
|
||||
|
@ -89,6 +83,11 @@ namespace Tetris {
|
|||
|
||||
// Inner loop for actual Gameplay
|
||||
score = 0;
|
||||
// Initialize board
|
||||
if (!hasStarted) {
|
||||
initBoard();
|
||||
hasStarted = true;
|
||||
}
|
||||
gameOver = false;
|
||||
while (!gameOver) {
|
||||
// Start of Frame
|
||||
|
@ -216,39 +215,41 @@ namespace Tetris {
|
|||
for (int i = 0; i < board.GetLength(0); i++)
|
||||
for (int j = 0; j < board.GetLength(1); j++)
|
||||
board[i, j] = black;
|
||||
|
||||
// P
|
||||
for (int i = 0; i < 8; i++)
|
||||
board[1, 13 + i] = colors[4];
|
||||
board[2, 13] = colors[4];
|
||||
board[3, 13] = colors[4];
|
||||
board[4, 14] = colors[4];
|
||||
board[4, 15] = colors[4];
|
||||
board[2, 16] = colors[4];
|
||||
board[3, 16] = colors[4];
|
||||
|
||||
// T
|
||||
for (int i = 0; i < 8; i++)
|
||||
board[5, 11 + i] = colors[5];
|
||||
board[3, 11] = colors[5];
|
||||
board[4, 11] = colors[5];
|
||||
board[6, 11] = colors[5];
|
||||
board[7, 11] = colors[5];
|
||||
|
||||
// B
|
||||
for (int i = 0; i < 8; i++)
|
||||
board[6, 13 + i] = colors[4];
|
||||
board[7, 13] = colors[4];
|
||||
board[8, 13] = colors[4];
|
||||
board[9, 14] = colors[4];
|
||||
board[9, 15] = colors[4];
|
||||
board[7, 16] = colors[4];
|
||||
board[8, 16] = colors[4];
|
||||
board[9, 17] = colors[4];
|
||||
board[9, 18] = colors[4];
|
||||
board[9, 19] = colors[4];
|
||||
board[7, 20] = colors[4];
|
||||
board[8, 20] = colors[4];
|
||||
|
||||
if (ptbLogo) {
|
||||
// P
|
||||
for (int i = 0; i < 8; i++)
|
||||
board[1, 13 + i] = colors[4];
|
||||
board[2, 13] = colors[4];
|
||||
board[3, 13] = colors[4];
|
||||
board[4, 14] = colors[4];
|
||||
board[4, 15] = colors[4];
|
||||
board[2, 16] = colors[4];
|
||||
board[3, 16] = colors[4];
|
||||
|
||||
// T
|
||||
for (int i = 0; i < 8; i++)
|
||||
board[5, 11 + i] = colors[5];
|
||||
board[3, 11] = colors[5];
|
||||
board[4, 11] = colors[5];
|
||||
board[6, 11] = colors[5];
|
||||
board[7, 11] = colors[5];
|
||||
|
||||
// B
|
||||
for (int i = 0; i < 8; i++)
|
||||
board[6, 13 + i] = colors[4];
|
||||
board[7, 13] = colors[4];
|
||||
board[8, 13] = colors[4];
|
||||
board[9, 14] = colors[4];
|
||||
board[9, 15] = colors[4];
|
||||
board[7, 16] = colors[4];
|
||||
board[8, 16] = colors[4];
|
||||
board[9, 17] = colors[4];
|
||||
board[9, 18] = colors[4];
|
||||
board[9, 19] = colors[4];
|
||||
board[7, 20] = colors[4];
|
||||
board[8, 20] = colors[4];
|
||||
}
|
||||
}
|
||||
|
||||
// Method to check whether a block at given coordinates collides with any other block or border
|
||||
|
@ -321,8 +322,8 @@ namespace Tetris {
|
|||
canSwap = true;
|
||||
// Otherwise reset game, because player has lost
|
||||
else {
|
||||
hasStarted = false;
|
||||
gameOver = true;
|
||||
initBoard();
|
||||
player = new();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user