added exit on unresponsive

This commit is contained in:
Baipyrus 2022-10-19 14:59:43 +02:00
parent 5200943396
commit 13b59a4d55

View File

@ -144,6 +144,7 @@ namespace Tetris {
canvas.DrawText(font, 0, 32, col, "1) Weiter");
canvas = matrix.SwapOnVsync(canvas);
int fC = 0;
bool selection = true;
while (selection) {
// Handle key presses for continue game or exit
@ -159,6 +160,14 @@ namespace Tetris {
}
}
// Exit if no response for 30 secs
if (fC >= 300) {
selection = false;
startOver = false;
}
// Wait for input
fC++;
Thread.Sleep(100);
}
}
@ -227,6 +236,7 @@ namespace Tetris {
for (int i = 0; i < board.GetLength(0); i++)
for (int j = 0; j < board.GetLength(1); j++)
board[i, j] = black;
player = new();
score = 0;
}
}
@ -281,7 +291,6 @@ namespace Tetris {
break;
case ConsoleKey.A:
// Rotate block counter-clockwise
// player.positions = rotateByAngle(player.positions, Math.PI / 2);
foreach (int[] a in player.positions) {
int temp = a[1];
a[1] = bounds - 1 - a[0];
@ -313,7 +322,6 @@ namespace Tetris {
break;
case ConsoleKey.D:
// Rotate block clockwise
// player.positions = rotateByAngle(player.positions, Math.PI/2);
foreach (int[] a in player.positions) {
int temp = a[0];
a[0] = bounds - 1 - a[1];