当前位置: 首页>>代码示例>>Python>>正文


Python Clock.start方法代码示例

本文整理汇总了Python中clock.Clock.start方法的典型用法代码示例。如果您正苦于以下问题:Python Clock.start方法的具体用法?Python Clock.start怎么用?Python Clock.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在clock.Clock的用法示例。


在下文中一共展示了Clock.start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import start [as 别名]
    def run(self):
        """Method that starts the game running."""

        timeController = Clock(self.S_TURN)

        self.isRunning = True
        while self.isRunning:
            # start turn
            timeController.start()
            leftTime = self.S_TURN

            #TODO think if input should be processed inside the inner loop
            # process user input to Game
            self.iMngr.processUserInput(self)
            #isRunning = not self.iMngr.closedGame()

            while timeController.time_left() > self.S_UPDATE:
                #sync with remote
                self.nMngr.updateGame(self)

                # update state of the game
                self.uMngr.updateGame(self)
                #newState = self.readState()
                #self.world.update(newState)

            # play sounds
            self.sMngr.updateGame(self)
            # render
            self.gMngr.draw(timeController.time_left(), self)
            #self.worldView.draw()

            # sleep if necessary
            timeController.sleep()
开发者ID:jclopes,项目名称:ZGame,代码行数:35,代码来源:zgame.py

示例2: main

# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import start [as 别名]
def main():
    database = Database()
    alarmLog = AlarmLog()
    summarizer = Summarizer(database, alarmLog)
    clock = Clock(summarizer)
    alarmWriter = AlarmWriter(summarizer)
    driver1 = Driver(1, summarizer)

    clock.start()
    alarmWriter.start()
    driver1.start()
    sleep(1000)
开发者ID:paskma,项目名称:framework-parlib,代码行数:14,代码来源:themain.py

示例3: main

# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import start [as 别名]
def main():
    cliMngr = ClientManager()
    clock = Clock(FRAMETIME)

    clock.start()
    while True:
        state = '{"team":[[10,10]],[[10,20]]}'
        # check if there are new clients trying to conect
        cliMngr.receive_connections()
        # send game state to all clients
        cliMngr.broadcast(state)
        # read clients input while we can
        timeout = clock.time_left()
        cliMngr.read_incoming_msgs(timeout)
        # drop clients that are not responsive
        cliMngr.check_clients_liveness()

        clock.sleep()
开发者ID:jclopes,项目名称:ZGame,代码行数:20,代码来源:server.py

示例4: main

# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import start [as 别名]
def main(srvHost, srvPort):
    w = dict()
    em = EventManager()
    nm = NetworkManager(em, w)
    FRAME_TIME = 0.2  # 200 ms
    c = Clock(FRAME_TIME)
    c.start()
    slept_time = 0.0
    nm.start(srvHost, srvPort)
    counter = 100
    exit = False
    while not exit:
        nm.update(slept_time + c.time_passed())
        counter -= 1
        if counter <= 0:
            exit = True
        slept_time = c.time_left()
        c.sleep()
        print "%s" % (counter * FRAME_TIME)
开发者ID:jclopes,项目名称:ZGame,代码行数:21,代码来源:networkmanager.py

示例5: Clock

# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import start [as 别名]
black = (0, 0, 0)

if __name__ == "__main__":
	pygame.init()

	# screen = pygame.display.set_mode(screen_size)
	screen = pygame.display.set_mode(screen_size, pygame.FULLSCREEN)
	pygame.display.set_caption("Wallhack")

	background = pygame.surface.Surface(screen_size)
	background.fill(black)

	pygame.draw.rect(background, green, (0, 0, screen_size[0], screen_size[1]), 4)

	clock = Clock()
	clock.start()

	eta = ETA(screen_size, rpcserver, clock)
	eta.start()

	chaos = Chaos(screen_size, rpcserver, clock)
	chaos.start()

	# subraum = Subraum(screen_size, clock)
	# subraum.start()

	# modules = [ (eta, eta.get_timeout), (chaos, lambda: 4) ]
	# modules = [ (chaos, lambda: float("infinity")) ]
	modules = [ (eta, lambda: float("infinity")) ]
	mod = 0
	mod_timer = time.time()
开发者ID:farhaven,项目名称:wallhack_display,代码行数:33,代码来源:hack.py

示例6: __repr__

# 需要导入模块: from clock import Clock [as 别名]
# 或者: from clock.Clock import start [as 别名]
class Mode:
    """ 
    A mode has its own clock, event manager, and components.
    A mode is a state activated and deactivated by the mode state machine.
    """

    def __repr__(self):
        return self.__class__.__name__
    def __str__(self):
        return self.__repr__()


    def __init__(self):
        """ When a mode is created, it only creates an event manager.
        The mode's components and clock are instantiated 
        when the mode is activated.
        The mode manager/MSM has to register for transition or quit callbacks 
        through set_X_callback.
        """

        # hold instances of the mode's components when the mode is activated
        self.active_components = []
        self.clock = None # instantiated by MSM
        self.em = EventManager() # each mode has its own EM


    def set_transition_callback(self, trans_evt_classes, msm_transition_cb):
        """ Set the callback to the mode state machine
        when transition events are fired by the current mode.
        """
        for ev_class in trans_evt_classes:
            self.em.subscribe(ev_class, msm_transition_cb)

    def set_quit_callback(self, msm_quit_cb):
        """ Set the MSM callback to call when the mode fires a QuitEvent. """
        self.em.subscribe(QuitEvent, msm_quit_cb)


    def activate(self, ev):
        """ Instantiate the components and clock for the mode. 
        The event passed in argument contains data sent by the previous mode.
        For example, the LevelTransitionMode sends a GameStart event
        containing the next level number to the GameMode. This way, the GameMode
        knows which level to instantiate. The GameMode sends a GameWon event
        containing the score to the LevelTransitionMode so that it can be 
        displayed.
        Small drawback: to keep the code generic, ALL the components are given 
        in argument the mode's EM and the event. Some components may not need 
        the event, but we can't know in advance, so we pass it anyway.
        """
        em = self.em
        self.active_components = [comp(em, ev) for comp in self.components]
        self.clock = Clock(em)
        self.clock.start() # returns when the clock is turned off, ie transition or quit 

        self.em.clear() # this removes the clock and MSM from the EM subscribers
        self.active_components = [] # last ref to component instances is lost
        self.clock = None


    def deactivate(self):
        """ Tell the clock to stop. 
        The mode's components will be garbage collected
        when the clock returns the hand back to the MSM. 
        """
        self.clock.stop()
开发者ID:gentimouton,项目名称:smofac,代码行数:68,代码来源:mode.py


注:本文中的clock.Clock.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。