realign(ships[selected]) # Game in progress (after user presses start): elif not setup: for event in pygame.event.get(): if event.type == pygame.QUIT: # If user clicked close carryOn = False # Flag that we are done so we exit this loop # If it's the player's turn and they press on a square that hasn't been pressed before: take a shot elif player_turn and event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1 and event.pos[0] < 660: coordinates = convert_pixel_coordinates( event.pos[0], event.pos[1]) # Take a shot last_player_attack = AI.suffer_attack(coordinates) # Check for sunken ships: AI.check_sunken_ships() # Update display board_array = AI.get_board() update_player_grid(board_array) wait_for(800) # Check if player wins: if AI.check_loss(): player_win = True carryOn = False # Update turn: If last turn was a hit or sink, go again if last_player_attack == Cell.HIT or last_player_attack == Cell.SUNK: player_turn = True AI_turn = False else: