Browse Source

reset game

main
Michael Pilosov 7 months ago
parent
commit
d59f05e33a
  1. 12
      main.py
  2. 2
      requirements.txt

12
main.py

@ -72,6 +72,14 @@ def display_board(board, piece, i, j):
print() 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(): def main():
board = np.zeros((20, 10), dtype=int) board = np.zeros((20, 10), dtype=int)
piece_types = list(PIECES.keys()) piece_types = list(PIECES.keys())
@ -82,6 +90,10 @@ def main():
while True: while True:
display_board(board, current_piece, i, j) display_board(board, current_piece, i, j)
if not check_placement(current_piece, board, *START_POS):
board = game_over(board)
continue
command = input( command = input(
"Enter command (a=left, d=right, s=down, w=rotate, S=drop, G=toggle gravity, Q=quit): " "Enter command (a=left, d=right, s=down, w=rotate, S=drop, G=toggle gravity, Q=quit): "
) )

2
requirements.txt

@ -0,0 +1,2 @@
numpy
Loading…
Cancel
Save