def main(): battlefield = BattleField() print('\nWelcome to the Battleship game!') choice = '' possible_choices = [1, 2, 3, 0] while choice not in possible_choices: print('1) for 2 Players\n2) for 1 Player\n3) for PC vs PC\n0) Exit') try: choice = int(input("Choose game mode: ")) except ValueError: print("Wrong choice!") if choice == 1: battlefield.start_pvp_game() elif choice == 2: battlefield.start_pvc_game() elif choice == 3: battlefield.start_cvc_game() elif choice == 0: exit()
from select import Select as Select_Window from battlefield import BattleField from graphic import draw_congratulation if __name__ == '__main__': # Инициализируем объекты pygame.init() screen = pygame.display.set_mode((SIZE_FIELD * WIDTH, SIZE_FIELD * HEIGHT)) pygame.display.set_caption('Sea Battle') Menu = Start_Menu(screen) Select = Select_Window(screen) player_1 = Player(screen, 'Player 1') player_2 = Player(screen, 'Player 2') Event = Event_in_game(screen, player_1) AI = AI_helper() BF = BattleField(screen, player_1, player_2) Menu.draw_menu() pygame.display.flip() player = player_1 while True: # цикл отслеживающий события for event in pygame.event.get(): pos = pygame.mouse.get_pos() if event.type == pygame.QUIT: sys.exit() if Event.menu: # если пользователь находится в меню if event.type == pygame.MOUSEBUTTONUP: Event.event_menu(Menu, pos, Select) elif Event.settings: # если пользователь находится в настройках if event.type == pygame.MOUSEBUTTONUP: