Пример #1
0
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)
Пример #2
0
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)