def run(gameStateObj, metaDataObj): my_list = gameStateObj.stateMachine.state[-5:] while True: if cf.OPTIONS['debug']: my_new_list = gameStateObj.stateMachine.state[-5:] if my_new_list != my_list: logger.debug('Current states %s', [state.name for state in gameStateObj.stateMachine.state]) my_list = my_new_list # logger.debug('Active Menu %s', gameStateObj.activeMenu) Engine.update_time() # Get events eventList = Engine.build_event_list() # === UPDATE USER STATES === mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) while repeat: # We don't need to process the eventList more than once I think mapSurf, repeat = gameStateObj.stateMachine.update([], gameStateObj, metaDataObj) # Update global sprite counters GC.PASSIVESPRITECOUNTER.update() GC.ACTIVESPRITECOUNTER.update() GC.CURSORSPRITECOUNTER.update() # Update global music thread Engine.music_thread.update(eventList) new_size = (GC.WINWIDTH * cf.OPTIONS['Screen Size'], GC.WINHEIGHT * cf.OPTIONS['Screen Size']) Engine.push_display(mapSurf, new_size, GC.DISPLAYSURF) # Keep gameloop (update, renders, etc) ticking Engine.update_display() gameStateObj.playtime += GC.FPSCLOCK.tick(GC.FPS)
def run(gameStateObj, metaDataObj): gameStateObj.message.append(Dialogue.Dialogue_Scene('Data/fight_quote_info.txt', event_flag=False, if_flag=True)) gameStateObj.stateMachine.changeState('dialogue') counter = 0 while gameStateObj.message: Engine.update_time() counter += 1 if not counter%50: pyautogui.press('x') eventList = Engine.build_event_list() mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) while repeat: mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) GC.DISPLAYSURF.blit(mapSurf, (0, 0)) pygame.display.update()
def run(gameStateObj, metaDataObj): while True: Engine.update_time() # Get events eventList = Engine.build_event_list() # Update global music thread Engine.music_thread.update(eventList) # === UPDATE USER STATES === mapSurf, repeat = gameStateObj.stateMachine.update( eventList, gameStateObj, metaDataObj) while repeat: # We don't need to process the eventList more than once I think mapSurf, repeat = gameStateObj.stateMachine.update([], gameStateObj, metaDataObj) # Update global sprite counters GC.PASSIVESPRITECOUNTER.update() GC.ACTIVESPRITECOUNTER.update() GC.CURSORSPRITECOUNTER.update() #new_size = (cf.OPTIONS['Screen Width'], cf.OPTIONS['Screen Height']) draw_rect = GC.TEMPCANVASRECT Engine.push_display(mapSurf, (draw_rect[2], draw_rect[3]), GC.TEMPCANVAS) GC.DISPLAYSURF.blit(GC.TEMPCANVAS, draw_rect) #Engine.push_display(mapSurf, new_size, GC.DISPLAYSURF) # Check for taking screenshot for event in eventList: if event.type == Engine.KEYDOWN and event.key == Engine.key_map[ '`']: current_time = str(datetime.now()).replace(' ', '_').replace( ':', '.') Engine.save_surface(mapSurf, "Lex_Talionis_%s.png" % current_time) # Keep gameloop (update, renders, etc) ticking Engine.update_display() gameStateObj.playtime += GC.FPSCLOCK.tick(GC.FPS)
def run(gameStateObj, metaDataObj, fp): if os.path.exists(fp): print(fp) gameStateObj.message.append(Dialogue.Dialogue_Scene(fp, unit=gameStateObj.allunits[0], if_flag=True)) gameStateObj.stateMachine.changeState('dialogue') counter = 0 while gameStateObj.message: Engine.update_time() counter += 1 if not counter%50: pyautogui.press('x') eventList = Engine.build_event_list() mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) while repeat: mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) GC.DISPLAYSURF.blit(mapSurf, (0, 0)) pygame.display.update()
def run(gameStateObj, metaDataObj, unit): print(unit.name) unit.isDying = True gameStateObj.stateMachine.changeState('dying') gameStateObj.message.append(Dialogue.Dialogue_Scene(metaDataObj['death_quotes'], unit, event_flag=False)) gameStateObj.stateMachine.changeState('dialogue') counter = 0 while gameStateObj.message: Engine.update_time() counter += 1 if not counter%50: pyautogui.press('x') eventList = Engine.build_event_list() mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) while repeat: mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) GC.DISPLAYSURF.blit(mapSurf, (0, 0)) pygame.display.update()
def main(): gameStateObj = GameStateObj.GameStateObj() metaDataObj = {} gameStateObj.build_new() done = False for num in range(0, 12): if hasattr(gameStateObj, 'saving_thread'): gameStateObj.saving_thread.join() gameStateObj.save_slots = Transitions.load_saves() print('Level: %s' % num) gameStateObj.build_new() # Make the gameStateObj ready for a new game gameStateObj.set_generic_mode() gameStateObj.save_slot = 0 levelfolder = 'Assets/Lex-Talionis/Data/Level' + str(num) # Create a save for the first game gameStateObj.stateMachine.clear() gameStateObj.stateMachine.changeState('turn_change') SaveLoad.suspendGame(gameStateObj, "Start", slot=gameStateObj.save_slot) # Load the first level SaveLoad.load_level(levelfolder, gameStateObj, metaDataObj) # Set Casual Mode gameStateObj.mode['death'] = 0 # Run counter = 0 suspended_yet, dead_yet = False, False while not done: Engine.update_time() current_state = gameStateObj.stateMachine.getState() if current_state == 'free': units = [unit for unit in gameStateObj.allunits if unit.team == 'player' and not unit.dead and unit.name not in {'Sam', 'Ophie', 'Prim', 'Renae'}] if not dead_yet and units: unit = units[0] print(unit.name) unit.isDying = True gameStateObj.stateMachine.changeState('dying') gameStateObj.message.append(Dialogue.Dialogue_Scene(metaDataObj['death_quotes'], unit=unit)) gameStateObj.stateMachine.changeState('dialogue') dead_yet = True elif suspended_yet: gameStateObj.statedict['levelIsComplete'] = 'win' gameStateObj.message.append(Dialogue.Dialogue_Scene('Assets/Lex-Talionis/Data/seizeScript.txt')) gameStateObj.stateMachine.changeState('dialogue') suspended_yet = False else: SaveLoad.suspendGame(gameStateObj, 'Suspend', hard_loc='Suspend') gameStateObj.save_slots = None # Reset save slots gameStateObj.stateMachine.clear() gameStateObj.stateMachine.changeState('start_start') suspended_yet = True elif current_state == 'start_save' or current_state == 'start_start' or current_state == 'start_option': pyautogui.press('x') if current_state == 'start_save': dead_yet = False elif current_state == 'move': pyautogui.press('z') counter += 1 if not counter%20: pyautogui.press('s') eventList = Engine.build_event_list() mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) while repeat: mapSurf, repeat = gameStateObj.stateMachine.update(eventList, gameStateObj, metaDataObj) GC.DISPLAYSURF.blit(mapSurf, (0, 0)) pygame.display.update() gameStateObj.playtime += GC.FPSCLOCK.tick(GC.FPS)