From d59f05e33afb354ede36d5d94cf6686010892730 Mon Sep 17 00:00:00 2001 From: Michael Pilosov Date: Thu, 9 May 2024 17:06:01 -0600 Subject: [PATCH] reset game --- main.py | 12 ++++++++++++ requirements.txt | 2 ++ 2 files changed, 14 insertions(+) create mode 100644 requirements.txt diff --git a/main.py b/main.py index 6458aca..5dfdc26 100644 --- a/main.py +++ b/main.py @@ -72,6 +72,14 @@ def display_board(board, piece, i, j): print() +def game_over(board): + print("GAME OVER! The pieces reached the top.") + # Optionally clear the board or exit the game + return np.zeros_like( + board + ) # Clear the board and continue or call sys.exit() to end + + def main(): board = np.zeros((20, 10), dtype=int) piece_types = list(PIECES.keys()) @@ -82,6 +90,10 @@ def main(): while True: display_board(board, current_piece, i, j) + if not check_placement(current_piece, board, *START_POS): + board = game_over(board) + continue + command = input( "Enter command (a=left, d=right, s=down, w=rotate, S=drop, G=toggle gravity, Q=quit): " ) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b26e81f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +numpy +