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


Python StateMachine.update方法代码示例

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


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

示例1: Wife

# 需要导入模块: from statemachine import StateMachine [as 别名]
# 或者: from statemachine.StateMachine import update [as 别名]
class Wife(BaseGameEntity):
    def __init__(self, name):
        self.name = name
        self.fsm = StateMachine(self)
        self.fsm.set_current_state(states.DoHouseWork())
        self.fsm.set_global_state(states.WifeGlobalState())

    def update(self):
        self.fsm.update()

    def handle_msg(self, sender, msg):
        return self.fsm.handle_message(sender, self, msg)
开发者ID:xiangxiaobaog3,项目名称:codelab,代码行数:14,代码来源:miner.py

示例2: __init__

# 需要导入模块: from statemachine import StateMachine [as 别名]
# 或者: from statemachine.StateMachine import update [as 别名]

#.........这里部分代码省略.........
            previousAButton = previousControllerState['aButton']
            previousBButton = previousControllerState['bButton']
            previousCButton = previousControllerState['cButton']
            previousDButton = previousControllerState['dButton']
            aChanged = previousAButton != aButton
            bChanged = previousBButton != bButton
            cChanged = previousCButton != cButton
            dChanged = previousDButton != dButton

            if aChanged or bChanged:
                self.onButtonChanged(player, aButton, bButton, previousAButton, previousBButton)

                previousControllerState['aButton'] = aButton
                previousControllerState['bButton'] = bButton

            if cChanged:
                if not cButton:
                    self._onChangeOrientation(player)

                previousControllerState['cButton'] = cButton

            if dChanged:
                if not dButton:
                    self.onStartMenuTriggered(player)

                previousControllerState['dButton'] = dButton

    def run(self):
        clock = pygame.time.Clock()
        while True:
            dt = clock.tick(self.framerate) / 1000.0
            #dt = time.time() - self.lastFrame

            self.update(dt)

            self.draw(self.rgb)

            self.rgb.send()

            self.lastFrame = time.time()

    def update(self, dt):
        self.poll(dt)

        self.stateMachine.update(dt)

    def draw(self, rgb):
        rgb.clear(BLACK)

        self.stateMachine.draw(rgb)

    def onAxisChanged(self, player, xAxis, yAxis, previousXAxis, previousYAxis):
        #todo rotation

        if (self._notIsZero(xAxis) and self._isZero(previousXAxis)) or \
           (self._notIsZero(yAxis) and self._isZero(previousYAxis)):

            x = 1 if xAxis > 0.1 else 0
            x = -1 if xAxis < -0.1 else x
            y = 1 if yAxis > 0.1 else 0
            y = -1 if yAxis < -0.1 else y

            if x != 0 or y != 0:
                self.onClampedAxisChanged(player, x, y)

        self.stateMachine.onAxisChanged(player, xAxis, yAxis, previousXAxis, previousYAxis)
开发者ID:honkomonk,项目名称:96pxgames,代码行数:70,代码来源:game.py


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