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 +