reset game
This commit is contained in:
parent
d73ab1bbcf
commit
d59f05e33a
12
main.py
12
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): "
|
||||
)
|
||||
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
numpy
|
||||
|
Loading…
Reference in New Issue
Block a user