def redrawAll(self, screen): if self.state == "start": Start.redrawAll(self, screen) elif self.state == "game": GamePlay.redrawAll(self, screen) elif self.state == "score": ScoreBoard.redrawAll(self, screen)
def __init__(self): self.running = True self.UC = Udp_communication(socket, pickle, self.server_ip, self.server_port) self.state = Start(self.UC, bge, ras) #THIS JUST FORWARDS TO LOBBY, UPDATE IT. self.input = Input(bge)
def __init__(self): pygame.init() pygame.mixer.pre_init(44100, 16, 2, 4096) self.settings = Settings() self.settings.start_intro_music() self.screen = pygame.display.set_mode((self.settings.screen_width, self.settings.screen_height)) pygame.display.set_caption("Pacman Portal") self.clock = pygame.time.Clock() self.radius = 1 self.start = 1 self.end = 10 self.begin = pygame.time.get_ticks() self.wait = 800 self.startup = Start(self.screen, self.settings) self.stats = Stats(self.settings) self.sb = Scoreboard(self.settings, self.screen, self.stats) self.maze = Maze(self.screen, mazefile='images/pacman_portal_maze.txt', brickfile='square', orangeportalfile='portal_orange', blueportalfile='portal_blue', shieldfile='shield', pointfile='point_pill', gatefile="gate") self.pacman = Pacman(self.screen, mazefile='images/pacman_portal_maze.txt') self.red = Red(self.screen, mazefile='images/pacman_portal_maze.txt') self.blue = Blue(self.screen, mazefile='images/pacman_portal_maze.txt') self.orange = Orange(self.screen, mazefile='images/pacman_portal_maze.txt') self.pink = Pink(self.screen, mazefile='images/pacman_portal_maze.txt') self.inc = 0
def timerFired(self, dt): if self.state == "start": Start.timerFired(self, dt) elif self.state == "game": GamePlay.timerFired(self, dt) elif self.state == "score": ScoreBoard.timerFired(self, dt)
class Main(ShowBase): start = None lobby = None round = None def __init__(self): ShowBase.__init__(self) self.start = Start(self) def goToLobby(self): self.start.cleanup() self.start = None self.lobby = Lobby(self) self.lobby.show() def startRound(self): self.lobby.hide() self.round = Round(self) def endRound(self): self.round.destroy() del self.round self.round = None self.lobby.show() def quit(self): sys.exit()
def init(self): pygame.font.init() pygame.mixer.init() self.state = "start" # Start state Start.init(self) # Game state GamePlay.init(self)
def keyPressed(self, keyCode, mod): if self.state == "start": Start.keyPressed(self, keyCode, mod) elif self.state == "game": GamePlay.keyPressed(self, keyCode, mod) elif self.state == "score": ScoreBoard.keyPressed(self, keyCode, mod) if self.canShoot == False or self.gameOver or self.screen == "board": if keyCode == pygame.K_r: pygame.mixer.stop() Game.init(self)
def make_instance(start, duration, start_day): """ Return two class instances: start from Start and duration from Duration. """ start = Start(start, start_day) duration = Duration(duration) return start, duration
class Main: server_ip = "192.168.1.100" server_port = 5000 def __init__(self): self.running = True self.UC = Udp_communication(socket, pickle, self.server_ip, self.server_port) self.state = Start(self.UC, bge, ras) #THIS JUST FORWARDS TO LOBBY, UPDATE IT. self.input = Input(bge) def run(self): value = self.state.run() input_value = self.input.run() if input_value == None: pass elif input_value == "leaving_game": self.running = False if value == None: pass elif value == "lobby": self.state = Lobby(self.UC, ras, bge) elif value == "game_start": bge.logic.sendMessage("change_scene") if str(bge.logic.getCurrentScene()) == "game_scene": self.state = Game(bge, self.UC, pickle) elif "menu_scene": print("going back to start!") self.state = Start(self.UC, bge, ras)
def run_state_machine(self): current_state = Start(0) while not current_state.is_stop_state(): print "current state", current_state while not current_state.is_finished(): current_state.run() print "next input", current_state.next_input() current_state = current_state.next_state() print "done"
def set_game(self): # Create game objects dic_ships = {} dic_pos = {} list_ships_name = [] list_players = [] controller_obj = Game_Controller() start_obj = Start() dic_players = start_obj.start_game() # Check that players' input was received if not dic_players: return 'Game Over! We cannot play a game without players!' # Create ships names for key in sorted(dic_players.keys()): list_ships_name.append(key+'_'+'Sub_Attacker') list_ships_name.append(key+'_'+'Sub_Fixer') list_ships_name.append(key+'_'+'Sub_Master') # Instantiate ship objects and assign them to corresponding names in dictionary for i in range(0, len(dic_players)*3, 3): dic_ships[list_ships_name[i]] = Ship_A(list_ships_name[i]) dic_ships[list_ships_name[i+1]] = Ship_F(list_ships_name[i+1]) dic_ships[list_ships_name[i+2]] = Ship_M(list_ships_name[i+2]) # Distribute existing ships in initial random positions (dictionary # of positions) while list_ships_name: cur_pos = (random.randrange(0,100), random.randrange(0,100) , random.randrange(0,100)) if cur_pos in dic_pos: continue dic_pos[cur_pos] = list_ships_name.pop() # Randomly pick first player to play and put players in ordered list for key in sorted(dic_players.keys()): list_players.append(key) cur_player = random.randrange(0, len(list_players)) list_players = list_players[cur_player:] + list_players[:cur_player] # Send relevant game objects to the class that will start the game # and control its flow controller_obj.game_controller(dic_players, dic_ships, dic_pos , list_players)
def __init__(self, parent, controller): ttk.Notebook.__init__(self, parent) self.controller = controller self['style'] = 'lefttab.TNotebook' self.tab1_image = tk.PhotoImage(file='start.png', width=60) self.tab2_image = tk.PhotoImage(file='daily_rates.png', width=60) self.tab3_image = tk.PhotoImage(file='dossiers.png', width=60) self.tab4_image = tk.PhotoImage(file='networks.png', width=60) self.tab5_image = tk.PhotoImage(file='cash_flows.png', width=60) self.tab6_image = tk.PhotoImage(file='statements.png', width=60) self.tab7_image = tk.PhotoImage(file='daily_reports.png', width=60) self.tab8_image = tk.PhotoImage(file='settings.png', width=60) self.tab9_image = tk.PhotoImage(file='audit_trail.png', width=60) self.f1 = Start(parent.master, self) self.f2 = DailyRates(parent.master, self) self.f3 = tk.Frame(self) self.f4 = tk.Frame(self) self.f5 = Cashflows(parent.master, self) self.f6 = tk.Frame(self) self.f7 = DailyReports(parent.master, self) self.f8 = tk.Frame(self) self.f9 = tk.Frame(self) self.add(self.f1, text='Start', image=self.tab1_image, compound=tk.TOP) self.add(self.f2, text='Daily Rates', image=self.tab2_image, compound=tk.TOP) self.add(self.f3, text='Dossiers', image=self.tab3_image, compound=tk.TOP) self.add(self.f4, text='Networks', image=self.tab4_image, compound=tk.TOP) self.add(self.f5, text='Cash flows', image=self.tab5_image, compound=tk.TOP) self.add(self.f6, text='Statements', image=self.tab6_image, compound=tk.TOP) self.add(self.f7, text='Daily Reports', image=self.tab7_image, compound=tk.TOP) self.add(self.f8, text='Settings', image=self.tab8_image, compound=tk.TOP) self.add(self.f9, text='Audit Trail', image=self.tab9_image, compound=tk.TOP)
def run_game(): clock = pygame.time.Clock() # Initialize pygame, settings, and screen object. pygame.init() ai_settings = Settings() screen = pygame.display.set_mode( (ai_settings.screen_width, ai_settings.screen_height)) pygame.display.set_caption("Alien Invasion") # Make the Play button. play_button = Button(ai_settings, screen, "Play") # Create an instance to store game statistics, and a scoreboard. stats = GameStats(ai_settings) sb = Scoreboard(ai_settings, screen, stats) # Start start = Start(screen, stats) # Make a ship, a group of bullets, and a group of aliens. ship = Ship(ai_settings, screen) bullets = Group() bad_bullets = Group() aliens = Group() bunkers = Group() ufos = UFO(ai_settings, screen) # Create the fleet of aliens. gf.create_fleet(ai_settings, screen, aliens) # Create bunkers gf.create_bunkers(ai_settings, screen, bunkers) pygame.mixer.music.load('sounds/music.mp3') pygame.mixer.music.play(-1) # Start the main loop for the game. while True: gf.check_events(ai_settings, screen, stats, sb, play_button, ship, aliens, bullets, bad_bullets, start) if stats.game_active and stats.game_pause: # ship.update() ufos.update(screen) bad_bullets.update() gf.fire_bad_bullet(ai_settings, screen, aliens, bad_bullets) gf.update_bullets(ai_settings, screen, stats, sb, aliens, bullets, bunkers, bad_bullets, ufos) gf.update_aliens(ai_settings, screen, stats, sb, ship, aliens, bad_bullets) ship.update(stats) gf.update_screen(ai_settings, screen, stats, sb, ship, aliens, bullets, bad_bullets, play_button, bunkers, start, ufos) clock.tick(60)
def update(screen, sg): s = Start(screen) #横排放多少个 width = int((s.screen_rect.width - 2 * s.rect.width) / (2 * s.rect.width)) height = int( (s.screen_rect.height - 2 * s.rect.height) / (2 * s.rect.height)) for x in range(height): for y in range(width): st = Start(screen) random_number1 = randint(-20, 20) random_number2 = randint(-20, 20) st.rect.x = st.rect.width + (4 * st.rect.width) * y + random_number2 st.rect.y = st.rect.height + (4 * st.rect.height) * x + random_number1 sg.add(st)
def __init__(self): pygame.init() self.res = (800, 800) self.clock = pygame.time.Clock() self.victory = False #when full game has been completed self.start = Start(self.res) self.level1 = Level1(self.res) self.level2 = Level2(self.res) self.currLevel = self.start #starts on start screen
def run(self): value = self.state.run() input_value = self.input.run() if input_value == None: pass elif input_value == "leaving_game": self.running = False if value == None: pass elif value == "lobby": self.state = Lobby(self.UC, ras, bge) elif value == "game_start": bge.logic.sendMessage("change_scene") if str(bge.logic.getCurrentScene()) == "game_scene": self.state = Game(bge, self.UC, pickle) elif "menu_scene": print("going back to start!") self.state = Start(self.UC, bge, ras)
def start_menu_title(self): self.canvas.delete("all") self.canvas.configure(background=self.background) self.canvas.unbind("<Configure>") self.canvas.bind("<Configure>", self.canvas.on_resize) try: self.after_cancel(self.debug_update) except AttributeError: pass self.start = Start(self)
class Engine(object): Rooms = { 'start': Start(), 'death': Death(), 'finished': Finished() } def __init__(self, current_room_name): self.current_room = self.Rooms.get(current_room_name) def play_game(self): next_room_name = 'None' while next_room_name == 'None': self.current_room.enter_room() next_room_name = self.current_room.exit_room() self.current_room = self.Rooms.get(next_room_name) next_room_name = self.current_room.info.get('next_room')
def run(self): try: processes = {} while True: _port = 4723 devices = self.get_device() for serial in devices: if serial in processes: continue _port = utils.valid_port(_port) processes[str(serial)] = Start(serial, _port, self.app_name) _port += 1 time.sleep(10) processes = self.check_process(processes) except Exception as e: print("启动错误 {}".format(str(e)))
def run_game(): # Initialize game and create a screen object. pygame.init() screen = pygame.display.set_mode((800, 600)) pygame.display.set_caption("Pong") # Start screen start = Start(screen) # Draw line line = Line(screen) # Draw right side paddle right = VerticalPaddle(screen) right.rect.centery = right.screen_rect.centery right.rect.right = right.screen_rect.right # Draw Right top paddle right_top = HorizontalPaddle(screen) right_top.rect.top = right_top.screen_rect.top right_top.rect.centerx = right_top.screen_rect.centerx * 1.5 # Draw Right bottom paddle (align to right top paddle) right_bot = HorizontalPaddle(screen) right_bot.rect.bottom = right_bot.screen_rect.bottom right_bot.rect.centerx = right_top.rect.centerx # Draw left side paddle left = CPUVerticalPaddle(screen) left.rect.centery = left.screen_rect.centery left.rect.left = left.screen_rect.left # Draw CPU top paddle left_top = CPUHorizontalPaddle(screen) left_top.rect.top = left_top.screen_rect.top left_top.rect.centerx = left_top.screen_rect.centerx / 2 # Draw CPU bottom paddle left_bot = CPUHorizontalPaddle(screen) left_bot.rect.bottom = left_bot.screen_rect.bottom left_bot.rect.centerx = right_top.rect.centerx # Draw ball ball = Ball(screen) ball.rect.centerx = ball.screen_rect.centerx ball.rect.centery = ball.screen_rect.centery # Make game active to false ball.game_active = False # Start the main loop for the game while True: gf.check_events(right, right_top, ball, screen) if ball.start_active: start.start_blit(screen) start.start_update(ball) if ball.game_active: gf.update_screen(screen, line, right, right_top, right_bot, left, left_top, left_bot, ball, start) right.update() right_top.update() left.update(ball, start) left_top.update(ball, start) gf.check_ball(ball) gf.check_collisions(ball, right, right_top, right_bot, left, left_top, left_bot)
def Start_menu(self): self.start_menu = Start(self.screen) self.game_level = 1 self.is_2p = self.start_menu.draw()
class Game: BLACK = (0, 0, 0) def __init__(self): pygame.init() pygame.mixer.pre_init(44100, 16, 2, 4096) self.settings = Settings() self.settings.start_intro_music() self.screen = pygame.display.set_mode((self.settings.screen_width, self.settings.screen_height)) pygame.display.set_caption("Pacman Portal") self.clock = pygame.time.Clock() self.radius = 1 self.start = 1 self.end = 10 self.begin = pygame.time.get_ticks() self.wait = 800 self.startup = Start(self.screen, self.settings) self.stats = Stats(self.settings) self.sb = Scoreboard(self.settings, self.screen, self.stats) self.maze = Maze(self.screen, mazefile='images/pacman_portal_maze.txt', brickfile='square', orangeportalfile='portal_orange', blueportalfile='portal_blue', shieldfile='shield', pointfile='point_pill', gatefile="gate") self.pacman = Pacman(self.screen, mazefile='images/pacman_portal_maze.txt') self.red = Red(self.screen, mazefile='images/pacman_portal_maze.txt') self.blue = Blue(self.screen, mazefile='images/pacman_portal_maze.txt') self.orange = Orange(self.screen, mazefile='images/pacman_portal_maze.txt') self.pink = Pink(self.screen, mazefile='images/pacman_portal_maze.txt') self.inc = 0 def __str__(self): return 'Game(Pacman Portal), maze=' + str(self.maze) + ')' def open_portal(self, x, y, color): for r in range(self.start, self.end): pygame.gfxdraw.circle(self.screen, x, y, r, color) now = pygame.time.get_ticks() if now < self.begin + self.wait: self.inc = 1 elif now < self.begin + 4 * self.wait: self.inc = 0 else: self.inc = -1 self.start += self.inc self.start = max(1, self.start) self.end += self.inc def play(self): clock = pygame.time.Clock() eloop = EventLoop(finished=False) while not eloop.finished: eloop.check_events(self.screen, self.pacman, self.startup) if self.startup.playing: pygame.mixer.music.stop() if not self.settings.flag_chomp: self.settings.chomp_music() self.settings.flag_chomp = True self.settings.chomp_music() self.pacman.update(self.maze, self.settings, self.stats, self.sb, self.red, self.blue, self.orange, self.pink) self.red.update(self.maze, self.settings, self.stats, self.pacman, self.startup, self.blue, self.pink, self.orange, self.sb) self.blue.update(self.maze, self.settings, self.stats, self.pacman, self.startup, self.red, self.pink, self.orange, self.sb) self.orange.update(self.maze, self.settings, self.stats, self.pacman, self.startup, self.blue, self.pink, self.red, self.sb) self.pink.update(self.maze, self.settings, self.stats, self.pacman, self.startup, self.blue, self.red, self.orange, self.sb) self.update_screen() clock.tick(155) def update_screen(self): if not self.startup.playing: self.startup.draw_bg() self.startup.draw_button() else: self.screen.fill(Game.BLACK) self.maze.blitme() self.pacman.blitme() self.red.blitme() self.blue.blitme() self.orange.blitme() self.pink.blitme() self.open_portal(100, 100, (240, 100, 20)) self.sb.show_score() pygame.display.flip()
def keyPressed(self, keyCode, mod): if self.state == "start": Start.keyPressed(self, keyCode, mod) elif self.state == "game": GamePlay.keyPressed(self, keyCode, mod)
def run(self): # 游戏运行时主要有下面四件事 self.inputOrder() #1 接受外界输入指令 self.move() #2 接受命令后导致图片移动 if self.is_hero_hit_enemy(): # 如果飞机被撞结束游戏 self.is_over() self.blited() #3 图片重新绘制 self.update() #4 图片更新 def is_over(self): pygame.mixer.music.stop() # 停止背景音乐 boom_sound = pygame.mixer.Sound("res/gameover.wav") # 加载音效 boom_sound.play() # 播放音效 while True: event_list = pygame.event.get() for event in event_list: # 1. 鼠标点击关闭窗口事件 if event.type == pygame.QUIT: print("关闭了窗口") sys.exit() def main(self): while True: self.run() if __name__ == "__main__": # 防止下面的代码被导包 # 进分析游戏进程如下:游戏开始game.start,游戏运行game.run,游戏结束game.over start = Start() my_game = Game() # 创建一个游戏类 my_game.main()
from random import randrange from bird import Bird from bone import Bone from game_over import GameOver from get_key import ClearConsole, GetKey, Wait, WindowSize from laser import Laser from map import Map from paco import Paco from saver import Saver from start import Start if __name__ == '__main__': map = Map(133, 33, '#') start = Start(133, 33) finish = GameOver(133, 33) paconator = Paco(1, 15, 133, 33) getKey = GetKey() save = Saver() pigeons = [] lasers = [] bones = [] play_game = False game_over = False ammo = 20 points = 0 x = save.load() record = int(x) WindowSize() # ====== START SCREEN ======
############################################### LAB 6 ############################################## ################### Script written by Dr Alex Ter-Sarkisov@City, University of London, 2020 ############ ##################### DEEP LEARNING CLASSIFICATION, MSC IN ARTIFICIAL INTELLIGENCE ##################### ######################################################################################################## from PIL import Image as PILImage from resizeimage import resizeimage import os, sys, time import torch import torch.nn import torch.optim import torchvision.models as models from config import Config from deviceGpu import DeviceGpu from deviceGpu import DeviceType from start import Start from start import Finish from start import Hyperparam # Remember to update start info Start.start() DeviceGpu.get() # Put code in here # Example code: #device = DeviceGpu.device #lr = Hyperparam.lrate Finish.finish()
from microsoftbotframework import MsBot from start import Start bot = MsBot() start_obj = Start() bot.add_process(start_obj.process_message) if __name__ == '__main__': bot.run()
def __init__(self): ShowBase.__init__(self) self.start = Start(self)
class Game: def __init__(self): pygame.init() pygame.mixer.init() self.screen = pygame.display.set_mode((Screen_width, Screen_height)) pygame.display.set_caption(Game_name) self.clock = None self.music = None self.game_state = None self.is_2p = None self.score = None self.scoreP1 = None self.scoreP2 = None self.turnScore = None self.game_map = None self.tank_factory = None self.board = None self.game_level = 1 self.white = (255, 255, 255) self.red = (255, 0, 0) self.font = pygame.font.SysFont(None, 36) self.full_image = pygame.image.load(Full_path) self.tank_image = [] self.enemy_num = [0, 0, 0, 0] self.enemy_score = [100, 200, 300, 400] tank_Ypos = 6 while tank_Ypos <= 9: self.tank_image.append( self.full_image.subsurface( pygame.Rect((1 * 32, tank_Ypos * 32), (32, 32)))) tank_Ypos = tank_Ypos + 1 def Start_menu(self): self.start_menu = Start(self.screen) self.game_level = 1 self.is_2p = self.start_menu.draw() def prefstr(self, text, pos, color): self.text_image = self.font.render(text, True, color, Bg_color) self.screen.blit(self.text_image, pos) def prefnum(self, num, pos, color): self.text = "{:,}".format(num) self.text_image = self.font.render(self.text, True, color, Bg_color) self.screen.blit(self.text_image, pos) def draw_score_p1(self): while True: self.screen.fill(Bg_color) self.prefstr("Total Score : ", [50, 40], self.white) self.prefnum(self.score, [300, 40], self.red) self.prefstr("Score : ", [50, 80], self.white) self.prefnum(self.score, [300, 80], self.white) tank_num = 0 while tank_num <= 3: self.screen.blit(self.tank_image[tank_num], [50, 120 + tank_num * 50]) self.prefnum(self.tank_factory.tot_tank_type1[tank_num], [180, 130 + tank_num * 50], self.white) self.prefnum( self.tank_factory.tot_tank_type1[tank_num] * self.enemy_score[tank_num], [300, 130 + tank_num * 50], self.white) tank_num = tank_num + 1 self.prefstr("Press space to continue", [100, 350], self.white) pygame.display.update() for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_SPACE: return def draw_score_p2(self): score1, score2, count = 0, 0, 0 while count <= 3: score1 += self.tank_factory.tot_tank_type1[ count] * self.enemy_score[count] score2 += self.tank_factory.tot_tank_type2[ count] * self.enemy_score[count] count += 1 self.scoreP1 += score1 self.scoreP2 += score2 while True: self.screen.fill(Bg_color) self.prefstr("Player 1", [200, 5], self.white) self.prefstr("Player 2", [300, 5], self.white) self.prefstr("Total Score : ", [50, 40], self.white) self.prefnum(self.scoreP1, [250, 40], self.red) self.prefnum(self.scoreP2, [350, 40], self.red) self.prefstr("Score : ", [50, 80], self.white) self.prefnum(score1, [250, 80], self.white) self.prefnum(score2, [350, 80], self.white) tank_num = 0 while tank_num <= 3: self.screen.blit(self.tank_image[tank_num], [220, 120 + tank_num * 50]) self.prefnum(self.tank_factory.tot_tank_type1[tank_num], \ [150, 130 + tank_num * 50], self.white) self.prefnum(self.tank_factory.tot_tank_type1[tank_num]*\ self.enemy_score[tank_num], [50, 130 + tank_num * 50], self.white) self.prefnum(self.tank_factory.tot_tank_type2[tank_num], \ [310, 130 + tank_num * 50], self.white) self.prefnum(self.tank_factory.tot_tank_type2[tank_num]*\ self.enemy_score[tank_num], [390, 130 + tank_num * 50], self.white) tank_num = tank_num + 1 self.prefstr("Press space to continue", [100, 350], self.white) pygame.display.update() for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_SPACE: return def initialize(self): self.clock = pygame.time.Clock() self.music = GameMusic() self.game_state = State.Ok self.game_map = Map(self.screen, self.game_level) self.tank_factory = TankFactory(self.screen, Enemy_number, self.is_2p) self.board = Board(self.screen, self.tank_factory, self.is_2p, self.game_level) def start(self): self.music.play_game_start() self.score, self.scoreP1, self.scoreP2 = 0, 0, 0 while self.game_state == State.Ok: self.clock.tick(Clock_frequency) self.tank_factory.create() gf.check_events(self.tank_factory, self.music) self.turnScore = gf.update_screen(self.screen, self.game_map, self.tank_factory, self.music, self.board) self.score += self.turnScore gf.draw_screen(self.screen, self.game_map, self.tank_factory, self.board) self.game_state = gf.check_win(self.game_map, self.tank_factory) if self.game_state == State.Success: self.game_level += 1 if self.game_level > Max_level: self.game_level = 1 break else: if self.game_level >= 2: if self.is_2p: self.draw_score_p2() else: self.draw_score_p1() self.initialize() self.game_state = State.Ok self.game_level = 1 self.music.play_game_over() score1, score2, count = 0, 0, 0 while count <= 3: score1 += self.tank_factory.tot_tank_type1[ count] * self.enemy_score[count] score2 += self.tank_factory.tot_tank_type2[ count] * self.enemy_score[count] count += 1 self.scoreP1 += score1 self.scoreP2 += score2 self.end_menu = End(self.screen, self.tank_factory) if self.is_2p: self.end_menu.draw2p(self.scoreP1, self.scoreP2) else: self.end_menu.draw(self.score)
display = pygame.display.set_mode([1280, 720]) modoJogo = 1 def modo_de_jogo(value, difficulty): tipo, valor = value modo, valor = tipo global modoJogo modoJogo = valor pass menu = pygame_menu.Menu(720, 1280, 'Bem vindo ao UFF_Chess', theme=pygame_menu.themes.THEME_DARK) jogador1 = menu.add.text_input('Nome do jogador 1: ', default='1') jogador2 = menu.add.text_input('Nome do jogador 2: ', default='2') menu.add.selector('Modo de jogo :', [('Jogador vs Jogador', 1), ('Jogador vs IA', 2)], onchange=modo_de_jogo) menu.add.button('Jogar', menu.disable) menu.add.button('Sair', pygame_menu.events.EXIT) menu.mainloop(display) # Trocando o título windowIcon = pygame.image.load(ImagesPath.ICONE_PRETO) pygame.display.set_caption("UFF Chess") pygame.display.set_icon(windowIcon) jogador1 = jogador1.get_value() jogador2 = jogador2.get_value() tabuleiro = Tabuleiro(display=display, jogador1=jogador1, jogador2=jogador2, modo_de_jogo = modoJogo) start = Start(display, tabuleiro)