def main(): game_data = tools.create_game_data_dict() # Create a dictionary to keep track of game states. state_dict = { c.SANDY_COVE: states.MapState(c.SANDY_COVE), c.MYSTERIOUS_CAVE: states.MapState(c.MYSTERIOUS_CAVE), c.TRANQUIL_CABIN: states.MapState(c.TRANQUIL_CABIN), c.MAIN_MENU: menu.MainMenu(c.MAIN_MENU) } gm = tools.GameStatesManager() gm.setup(state_dict, c.MAIN_MENU) gm.state.start_up(game_data) clock = pg.time.Clock() while True: dt = clock.tick(c.FPS) / 32 events = pg.event.get() for event in events: if (event.type == pg.QUIT or event.type == pg.KEYDOWN and event.key == pg.K_ESCAPE): return keys = pg.key.get_pressed() # Update game state through GameStateManager. gm.update(setup.window, keys, dt, events) # Show fps in caption. fps = clock.get_fps() with_fps = f"{c.CAPTION} - {fps:.2f} FPS" pg.display.set_caption(with_fps)
def __init__(self, screen, clock): self.screen = screen self.clock = clock self.game_started = False self.quit_button = menu.MenuButton(display_width / 2 - 150, display_height / 2, quit_button_img, "quit") self.start_button = menu.MenuButton(display_width / 2 - 150, display_height / 4, start_button_img, "start") self.leaderboard_button = menu.MenuButton(display_width / 2 - 450, display_height / 6, leaderboard_button_img, "leaderboard") self.back_button = menu.MenuButton(display_width / 4, display_height - 100, back_button_img, "back") self.menu_table = menu.MainMenu(self.screen, self.quit_button, self.start_button, self.leaderboard_button) self.leaderboard_table = leaderboard.Leaderboard( leaderboard_storage, screen) self.create_start_leaderboard() self.death_screen_table = death_screen.Death_screen( screen, self.back_button) self.game_surface = terrain.Terrain() self.player = player.Player(PLAYER_POS_X, PLAYER_POS_Y, self.screen) self.army = player.AlienArmy(self.player, self.screen)
def main(): print '\nWelcome to Vehicle Shop System 0.1' this_menu = menu.MainMenu() # Create object from the class MainMenu while True: this_menu.get_main_menu() # Get the menu user_input = raw_input('> ') choice(user_input)
def __init__(self, stateManager): self.menuList = [] self.menuList.append(menu.MainMenu()) self.menuList.append(menu.LevelMenu(stateManager)) self.menuList.append(menu.OptionsMenu(stateManager)) self.curMenu = self.menuList[self.MAINMENU] self.stateManager = stateManager
def main(self): should_quit = False self.possible_enemies[100] = self.create_robot while not should_quit: should_quit = self.process_events() should_quit |= self.process() self.render(should_quit) pygame.display.update() # Quit game self.show_game_over() menu.MainMenu(self.screen)
def win(self): import os os.system('cls') print(""" __ __ __ ___ \ \ / /__ _ _ \ \ / (_)_ __ \ V / _ \| | | | \ \ /\ / /| | '_ \\ | | (_) | |_| | \ V V / | | | | | |_|\___/ \__,_| \_/\_/ |_|_| |_| """) print(" ------------------------------------------------------") print(" Final Gold: " + str(self.gold)) input(" Press enter to quit to main menu") Game.curGame.curScene.removeGameObjectsByType(DebugDisplay) Game.curGame.loadScene(menu.MainMenu()) Game.curGame.curScene.removeGameObject(self)
def update(self): kb = Game.curGame.keyboard if (kb.keyPressed(KeyCode.ESC)): if self.paused: self.paused = False self.removeGameObjectsByType(Popup) else: self.paused = True self.addGameObject(self.__popup) if self.hasAny(Popup): if (kb.keyPressed(KeyCode.ENTER)): activeOption = self.__popup.activeOption if activeOption == 0: self.saveGameMenu() elif activeOption == 1: self.loadGameMenu() elif activeOption == 2: Game.curGame.loadScene(menu.MainMenu())
def main(): USERDATA = loadUser() theMenu = menu.MainMenu(USERDATA) while True: mouseClicked = False mouseMoved = False SELECTION = "" for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() elif event.type == MOUSEMOTION: mouseX, mouseY = event.pos mouseMoved = True elif event.type == MOUSEBUTTONUP: mouseX, mouseY = event.pos mouseClicked = True if mouseClicked: SELECTION = theMenu.execute(mouseX, mouseY) if mouseMoved: theMenu.update(mouseX, mouseY) if SELECTION == menu.MainMenu.NEW_GAME: USERDATA["numGames"] += 1 saveUser(USERDATA) theMenu.resetAchievements(USERDATA) runGame(USERDATA) theMenu.resetAchievements(USERDATA) theMenu.redraw() elif SELECTION == menu.MainMenu.TRAINING or TRAINING_FLAG: runGame(USERDATA, useHintBox=True) theMenu.redraw() elif SELECTION == menu.MainMenu.EXIT_GAME: pygame.quit() sys.exit() pygame.display.update()
def lose(self): import os os.system('cls') print(""" _____ _____ | __ \ | _ | | | \/ __ _ _ __ ___ ___ | | | |_ _____ _ __ | | __ / _` | '_ ` _ \ / _ \ | | | \ \ / / _ \ '__| | |_\ \ (_| | | | | | | __/ \ \_/ /\ V / __/ | \____/\__,_|_| |_| |_|\___| \___/ \_/ \___|_| """) print(" ------------------------------------------------------") print(" You were killed by the enemy.") input(" Press enter to quit to main menu") Game.curGame.curScene.removeGameObjectsByType(DebugDisplay) Game.curGame.loadScene(menu.MainMenu()) Game.curGame.curScene.removeGameObject(self)
def __init__(self): self.screen = pygame.display.set_mode((self.screen_width,self.screen_height)) self.clock = pygame.time.Clock() self.mouseIsDown = False self.mouseRect = pygame.Rect(0,0,0,0) # The location of the upperleft hand corner of the # screen in relation to the entire playable surface self.upperleft = [0.0,0.0] # The location of where the mouse is clicked. Passed # down to map to do unit selection self.position1 = (0.0,0.0) self.arrowdown = False self.leftdown = False self.rightdown = False self.updown = False self.downdown = False self.map = map.Map.get() self.paused = False self.mainMenu = menu.MainMenu() self.spareMenu = menu.Menu() self.spareMenu.leave_menu()
def __init__(self): #constants self.INMENU = 0 #initiate pygame pygame.init() #setup main settings self.setUp_Settings() #initiate the screen if self.winMode == self.WINDOW: self.screen = pygame.display.set_mode(self.resolution) elif self.winMode == self.FULLSCREEN: self.screen = pygame.display.set_mode(self.resolution, pygame.FULLSCREEN) #initiate the game stages self.mainMenu = menu.MainMenu(self) #assing principal variables self.keepGoing = True self.stage = self.INMENU
def __init__(self, screen, img_hand, snd_hand, input_hand): self.screen = screen self.img_hand = img_hand self.snd_hand = snd_hand self.input_hand = input_hand self.main_menu = menu.MainMenu() self.pause_menu = menu.PauseMenu() self.editor_pause_menu = menu.EditorPauseMenu() self.level_select_menu = menu.LevelSelectMenu() self.editor_select_menu = menu.EditorSelectMenu() self.options_menu = menu.OptionsMenu() self.level_creation_menu = menu.LevelCreationMenu() self.credits = menu.Credits() self.level = None self.editor = None self.clock_text = textbox.Textbox( '', helpers.SCREEN_WIDTH - 0.5 * helpers.TILE_SIZE, 0) self.state = State.menu self.debug_enabled = False
def run_game(self, game: Game) -> None: """Runs the game""" pg.display.set_caption("Treasure Hunt game!") line_color = pg.Color('#8c8c91') # Initializes game loop booleans draw_general_path = False draw_all_path = False draw_path = False draw_grid = True show_all = False exit_game = False game_start = False player_set = False is_paused = False paths_import = False treasures_copied = False treasures_copy = [] # Create Game Menu Objects name_entry = menu.NameEntry(self.screen_size, self.screen) settings_menu = menu.Settings(self.screen_size, self.screen) main_menu = menu.MainMenu(self.screen_size, self.screen) pause = menu.Pause(self.screen_size, self.screen) # Initializes player rect object rect_size = (8, 8) rect_pos = (0, 0) player_rect = pg.Rect(rect_pos, rect_size) map_paths = [] general_path = Path((0, 0)) # Sets default map and path game.set_map(1) game.reset_path() # Initializes empty path list for the current map paths_colors = [pg.Color('#390ac0'), pg.Color('#188418'), pg.Color('#b81118'), pg.Color('#cb02a6'), pg.Color('#1584af'), pg.Color('#2bacc4'), pg.Color('#ac83b1'), pg.Color('#4ca13b'), pg.Color('#9c7463')] # Initialize music and sound pg.mixer.music.load('music/background.mp3') pg.mixer.music.set_volume(0.03) pg.mixer.music.play(-1) # river_sound = rock_sound = pg.mixer.Sound('music/rock.mp3') rock_sound.set_volume(0.1) treasure_sound = pg.mixer.Sound('music/treasure.wav') treasure_sound.set_volume(0.1) fragment_sound = pg.mixer.Sound('music/fragment.mp3') fragment_sound.set_volume(0.1) shortest_path_rect = [] while not exit_game: name_on = not player_set settings_on = False name_input = name_entry.display(name_on) if not player_set: game.player = Player(name_input) game.player.set_vision_radius(20) vision_radius = game.player.get_vision_radius() player_set = True if game_start: menu_on = False else: menu_on = True main_option = main_menu.display(menu_on) if main_option == 'Start': game.reset_path() rect_pos = game.path.initial_pos player_rect = pg.Rect(rect_pos, rect_size) game_start = True main_menu.return_option = '' elif main_option == 'Settings': settings_on = True elif main_option == 'Quit': exit_game = True else: pass settings_option = settings_menu.display(settings_on) if settings_option == 'logout': player_set = False settings_menu.option = '' map_id = settings_menu.map_id current_mode = settings_menu.mode # Sets game map id given by settings game.set_map(map_id) game.path.set_map(map_id) # Defines player movement step size h_step, v_step = game.game_map.get_step() if not paths_import: map_paths = [] for path_ in game.path_list: if path_.get_map() == map_id: map_paths.append(path_) paths_import = True # Generate the general path for the current map. This may slow down performance general_path = Path(initial_pos=(int(self.screen_size[0] / 40 - rect_size[0] / 2), int(self.screen_size[1] / 2 - rect_size[1] / 2))) general_path.set_map(map_id) general_path.set_general_paths(game.map_list[map_id-1], rect_size) # Obtains game objects from the map obstacle_list_type = [(x[0], x[1]) for x in game.game_map.get_obstacles()] obstacle_list = [x[0] for x in game.game_map.get_obstacles()] treasure_list = game.game_map.get_treasures() if not treasures_copied: treasures_copy = copy.deepcopy(treasure_list) treasures_copied = True fragment_list = game.game_map.get_fragments() # Retrieves object types and their relevant information object_type = game.game_map.get_object_types() # Change in position according to movement event dir_key = {K_LEFT: (-h_step, 0), K_RIGHT: (h_step, 0), K_UP: (0, -v_step), K_DOWN: (0, v_step)} # Assign keys to movement names dir_name = {K_LEFT: 'left', K_RIGHT: 'right', K_UP: 'up', K_DOWN: 'down'} # Assign keys to those for opposite direction. This is for reversing a move dir_opposite = {K_LEFT: K_RIGHT, K_RIGHT: K_LEFT, K_UP: K_DOWN, K_DOWN: K_UP} # Game window if game_start: # Checks for possible movements given obstacles in the current map possible_movements = ['left', 'right', 'up', 'down'] margins = [0, 800] available_movements = [] for move in possible_movements: new_pos = next_pos(rect_pos, move, h_step, v_step) center_pos = [new_pos[0] + rect_size[0] / 2, new_pos[1] + rect_size[1] / 2] new_rect = pg.Rect(new_pos, rect_size) if new_rect.collidelist(obstacle_list) == -1 and \ all(x not in margins for x in center_pos): available_movements.append(move) treasure_obtainable = True for event in pg.event.get(): if event.type == QUIT: exit_game = True pg.quit() if current_mode == 'Shortest Path': if player_rect.collidelist(treasures_copy) == -1: shortest_path = [] # Utilizes Shortest Path function if event.type == MOUSEBUTTONDOWN: init_pos = player_rect.topleft for fragment in fragment_list: if fragment.collidepoint(pg.mouse.get_pos()): final_pos = (int(fragment.centerx - rect_size[0] / 2), int(fragment.centery - rect_size[1] / 2)) shortest_path = general_path.shortest_path(init_pos, final_pos) for pos in shortest_path: path_rect_pos = (pos[0] + 2, pos[1] + 2) path_rect = pg.Rect(path_rect_pos, (4, 4)) shortest_path_rect.append(path_rect) pos_change = (pos[0] - init_pos[0], pos[1] - init_pos[1]) rect_pos = tuple(map(sum, zip(rect_pos, pos_change))) player_rect.move_ip(pos_change) game.path.update_path((int(rect_pos[0]), int(rect_pos[1]))) init_pos = rect_pos if event.type == KEYDOWN: if event.key in dir_key and dir_name[event.key] not in available_movements: rock_sound.play() # Assign rectangle movements according to key event if movement is valid if event.key in dir_key and dir_name[event.key] in available_movements: event_key = event.key pos_change = dir_key[event.key] rect_pos = tuple(map(sum, zip(rect_pos, pos_change))) player_rect.move_ip(pos_change) # Checks for fragment and treasure collision # Treasure Collision treasure_collision_index = player_rect.collidelist(treasure_list) if treasure_collision_index != -1: # With at least 3 fragments on treasure collision if game.player.backpack['fragments'] >= 3: treasure_sound.play() # Remove collided treasure from list del treasure_list[treasure_collision_index] game.player.update_backpack('treasures', 1) game.player.update_backpack('fragments', -3) # Not enough fragments on treasure collision else: treasure_obtainable = False # Moves player back to their last position pos_change = dir_key[dir_opposite[event_key]] rect_pos = tuple(map(sum, zip(rect_pos, pos_change))) player_rect.move_ip(pos_change) # Prints info message self.not_enough_fragment() if treasure_obtainable: game.path.update_path((int(rect_pos[0]), int(rect_pos[1]))) if event.key == K_f: show_all = not show_all if event.key == K_ESCAPE: is_paused = not is_paused if event.key == K_g: draw_grid = not draw_grid if event.key == K_p: draw_path = not draw_path if event.key == K_a: draw_all_path = not draw_all_path if event.key == K_h: draw_general_path = not draw_general_path # Fragment Collision fragment_collision_index = player_rect.collidelist(fragment_list) if fragment_collision_index != -1: fragment_sound.play() # remove collided fragment from list del fragment_list[fragment_collision_index] game.player.update_backpack('fragments', 1) # Fills screen self.screen.fill((248, 186, 182)) # Sets color for fragment and treasures treasure_color = pg.Color('#fdcc33') fragment_color = pg.Color('#f25805') if show_all: # Draws all game objects onto screen if show_all is True for o in obstacle_list_type: pg.draw.rect(self.screen, object_type[o[1]][0], o[0]) for treasure in treasure_list: pg.draw.rect(self.screen, treasure_color, treasure) for fragment in fragment_list: pg.draw.rect(self.screen, fragment_color, fragment) else: # Otherwise, utilizes vision field function path_pos = game.path.all_pos vision_rect_size = (rect_size[0] + 2 * vision_radius, rect_size[1] + 2 * vision_radius) vision_rect_pos = [(pos[0] - vision_radius, pos[1] - vision_radius) for pos in path_pos] vision_rects = [pg.Rect(pos, vision_rect_size) for pos in vision_rect_pos] for o in obstacle_list_type: if o[0].collidelist(vision_rects) != -1: pg.draw.rect(self.screen, object_type[o[1]][0], o[0]) for treasure in treasure_list: if treasure.collidelist(vision_rects) != -1: pg.draw.rect(self.screen, treasure_color, treasure) for fragment in fragment_list: if fragment.collidelist(vision_rects) != -1: pg.draw.rect(self.screen, '#ea4915', fragment) # Adds grid to the screen if draw_grid: self.draw_grid(40) for path_rect in shortest_path_rect: pg.draw.rect(self.screen, (35, 25, 25), path_rect) # Draws player rectangle object onto screen pg.draw.rect(self.screen, (255, 255, 255), player_rect) if pause.display(is_paused) == 'exit': player_rect.topleft = game.path.initial_pos game.reset_path() game.player.reset() game.game_map.reset() game_start = False paths_import = False treasures_copied = False shortest_path_rect.clear() pause.reset() is_paused = False if draw_all_path: # Draws all paths for the current map from previous games for i in range(len(map_paths)): if i < len(paths_colors) - 1: path_vertices = map_paths[i].get_graph().get_vertices().values() for vertex in path_vertices: pos = vertex.pos neighbours = vertex.neighbours for neighbour in neighbours: init_pos = (pos[0] + rect_size[0] / 2, pos[1] + rect_size[1] / 2) end_pos = (neighbour.pos[0] + rect_size[0] / 2, neighbour.pos[1] + rect_size[1] / 2) pg.draw.line(self.screen, paths_colors[i], init_pos, end_pos) if draw_general_path: # Draws all possible paths for the current game path_vertices = general_path.get_graph().get_vertices().values() for vertex in path_vertices: pos = vertex.pos neighbours = vertex.neighbours for neighbour in neighbours: init_pos = (pos[0] + rect_size[0] / 2, pos[1] + rect_size[1] / 2) end_pos = (neighbour.pos[0] + rect_size[0] / 2, neighbour.pos[1] + rect_size[1] / 2) pg.draw.line(self.screen, paths_colors[0], init_pos, end_pos) # Showing the path of the player if draw_path: path_vertices = game.path.get_graph().get_vertices().values() for vertex in path_vertices: pos = vertex.pos neighbours = vertex.neighbours for neighbour in neighbours: init_pos = (pos[0] + rect_size[0] / 2, pos[1] + rect_size[1] / 2) end_pos = (neighbour.pos[0] + rect_size[0] / 2, neighbour.pos[1] + rect_size[1] / 2) pg.draw.line(self.screen, line_color, init_pos, end_pos) # On winning game if game.player.backpack['treasures'] == game.game_map.get_difficulty(): # Keeps record of move_count move_count = copy.deepcopy(game.path.move_count) # Reset player position player_rect.topleft = game.path.initial_pos # Saves current game score to player data and resets player game.player.update_data(game.game_map.get_difficulty()) game.player.reset() # Saves the current path to file game.path.write_path() # The reset path function is part of the Game class, contrary to GameMap and Player # This is path requires a given map and player, which are obtained from game. game.reset_path() # Resets the game objects in the current GameMap game.game_map.reset() shortest_path_rect.clear() treasures_copied = False self.game_end(move_count) # Reread from files game = Game() game.read() game.set_map(map_id) paths_import = False game_start = False # Display current number of fragments and treasures the player has found self.show_score(game) pg.display.flip() self.clock.tick(60) pg.quit()
def main(): setup = menu.MainMenu() setup.run()
import menu as menu import functions as func __author__ = "Krikor Herlopian" __copyright__ = "Copyright 2021, University of New Haven Final Assignment" """ You need to run this file to run the application. python3 main.py """ #background color of window, and also listbox. Background color everywhere. bg_color = '#D9D9D9' root = Tk() #we need scrolling, we could have one million patients. scrollbar = Scrollbar(root) scrollbar.pack(side=RIGHT, fill=Y) #When patient file opened we want to remove all labels on screen and show listbox instead. pass this label_lst to menu to destroy it when loading patients file. label_lst = [] #this will be the label at start, before user loads new patient file. label = Label(root, text="Please load patient file", fg='#000000', bg=bg_color) label_lst.append(label) label.pack(side=TOP, anchor=NW) menubar = Menu(root) root.config(menu=menu.MainMenu(root, menubar, scrollbar, bg_color, label_lst)) #center the window, and initial size 400*300 func.center_window(root, 400, 300) #background of the window root.configure(background=bg_color) root.title("My Patient Program") root.mainloop()
def main_menu(self): self.unbind_game_keys() self.menu = menu.MainMenu(self) self.menu.grid(row=0, column=0, rowspan=3, columnspan=5, sticky='nsew')
settings = [ 5, # Lives [0, 0], # Characters ['Human', 'Bot'], # Player Types [0, 1], # Bot Difficulties 1, # Stage ] #First Screen Loaded into mode = "Start Menu" #load and play music pygame.mixer.music.load(os.path.join(cfg.music_dir, 'mainmenu.ogg')) pygame.mixer.music.play(-1,0) mode = menu.MainMenu(settings) # Runs Main Menu Screen #each function runs its own screen and outputs the screen it wants to go to while True: # Runs Game Loop if mode == "Character": # Character Select Screen mode , settings = menu.CharacterSelect(settings) elif mode == "Game": # Actual Game Screen mode , settings , loser = fight.fightLoop(settings) elif mode == "Results": # Help Menu Screen mode = menu.VictoryScreen(settings, loser) elif mode == "Stage": # Help Menu Screen mode , settings = menu.StageMenu(settings) # Runs Main Menu Screen elif mode == "Mode Menu": # Mode Select Screen mode , settings = menu.ModeMenu(settings) # Runs Mode Screen else: #Start Screen mode = menu.MainMenu(settings) # Runs Main Menu Screen
resizable=True) """Создание переходов и инициализация сцен""" lvl1 = lvl1_scene() lvl_locker = lvl1_locker() lvl_empty = lvl1_empty_locker() lvl3 = lvl3_scene() lvl2 = lvl2_scene() final = final_scene() """Инициализация меню основной сценой""" Menu = cocos.scene.Scene() background_layer = StaticImage("Resources/main_menu_bg.PNG", 1920 / 2, 1080 / 2, 1) set_m = set_scene(Menu) Menu.add(background_layer) Menu.add(menu.Settings(set_m)) Menu.add(menu.MainMenu(lvl1)) """Иницилизация сцен инвентаря и настроек""" set1 = set_scene(lvl1) box1 = box_scene(lvl1) small_menu_1 = small_menu.SmallMenu(set1, box1, Menu) set1 = set_scene(lvl_locker) box1 = box_scene(lvl_locker) small_menu_locker = small_menu.SmallMenu(set1, box1, Menu) set2 = set_scene(lvl2) box2 = box_scene(lvl2) small_menu_2 = small_menu.SmallMenu(set2, box2, Menu) set3 = set_scene(lvl3) box3 = box_scene(lvl3)
import menu from settings import * if __name__ == '__main__': """ It's the main module, it just import the settings, initialize some variables and create the main menu. """ for regex in regexsfilter: regexsfilter[ regex] = False # This line is to make sure that at the beginning no filter is active for regex in regexindex: regexindex[ regex] = 0 # This line is to make sure that every index of matches start at the first one main_menu = menu.MainMenu(regexs) main_menu.win.mainloop()
import pygame, os import config import menu from game import Point if __name__ == "__main__": print('loading...') options = config.OptionConfig() pygame.init() pygame.mixer.init() config.Screen() screen = pygame.Surface((320, 240), 0, 32) menu = menu.MainMenu(screen, Point(50, 140)) menu.mainloop()
def main(): args = parse_args() settings['debug'] = args.debug screen = init_screen() menu.MainMenu(screen)
def __init__(self, window): self.window = window self.active_env = None self.menu_env = menu.MainMenu(self.start_game, self.exit, window) self.level_env = game.Level(self.start_menu, self.window) self.start_menu()
sprite_z = (battle.getNumRows() - row) * 10 board.add(sprite.shadow, z=sprite_z) board.add(sprite, z=sprite_z + 1) for mech_name in player_mechs: mech = get_mech_by_name(mech_name) if mech is not None: add_mech_for_player(mech, player) for mech_name in bot_mechs: mech = get_mech_by_name(mech_name) if mech is not None: add_mech_for_player(mech, bot) # mix up the turn order battle.updateUnitsTurnOrder() scroller = cocos.layer.ScrollingManager() scroller.add(board, z=0) scroller.add(key_events, z=-1) scroller.add(mouse_events, z=1) battle.setScroller(scroller) scene = cocos.scene.Scene(menu.MainMenu(scroller)) director.run(scene)
def unclicked(self, m): super(ExitToMainOnClick, self).unclicked(m) m.nextMenu = menu.MainMenu()
def main_menu(screen): class_menu = mn.MainMenu(screen) next_link = class_menu.drawMainMenu() return next_link
import sys import pygame as pg import prepare # needs to be imported first to ensure correct initialization import custom import gameplay import menu import splashscreen states = { "Custom": custom.Custom(), "GamePlay": gameplay.GamePlay(), "NewGameMenu": menu.NewGameMenu(), "MainMenu": menu.MainMenu(), "SplashScreen": splashscreen.SplashScreen() } state = states[prepare.START_STATE_NAME] state.start(prepare.START_STATE_NAME, {}, pg.display.get_surface()) clock = pg.time.Clock() if __name__ == "__main__": while True: dt = clock.tick(prepare.FPS_MAX) # in milliseconds if pg.event.get(pg.QUIT) or state.quit: break state.process_events(pg.event.get()) if state.done: state.done = False persistent = state.persist next_state_name = state.next_state_name
def createMenuBar(self): import menu self.SetMenuBar( menu.MainMenu(self, self.settings, self.iocontroller, self.viewer, self.taskFile))
# Highlight all available boards CanvasHelper.higlight_available_boards(self.gameboard, self.game.available_boards()) # Display status def log_func(status): self.set_status(status) self.game.add_log_function(log_func) # Set status self.set_status("{} to play".format(self.game.active_player.name)) if __name__ == "__main__": root = tkinter.Tk() root.title("Ultimate XO") root.columnconfigure(0, weight=1) root.rowconfigure(0, weight=1) g = game.Game() main_window = MainWindow(root, g) main_window.grid(column=0, row=0, sticky=(N, W, E, S)) root.config(menu=menu.MainMenu(root, g, main_window)) root.update() root.minsize(root.winfo_width(), root.winfo_height()) root.mainloop()
# -*- coding: utf-8 -*- """ Created on Wed May 16 23:31:41 2018 @author: id1043 """ import menu import db lib = db.Library() lib.add_db(db.BaseDeDonnees("vinData.json")) main_menu = menu.MainMenu(lib) main_menu.start()
# Local Modules import menu if __name__ == '__main__': menu.MainMenu().run()