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


Python Hero.fixSpeed方法代码示例

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


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

示例1: Stage

# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import fixSpeed [as 别名]

#.........这里部分代码省略.........
        for gob in game_objects:
            gob.allocate_sprite()
            gob.show()
            gob.push_handlers(self)
            log.debug(D_SPAWN.format(type(gob).__name__,
                len(self.game_objects)))
        self.game_objects |= game_objects

    def spawn_projectile(self, projectile):
        projectile.allocate_sprite()
        projectile.align_sprite(self.offset)
        projectile.show()
        log.debug(D_SPAWN_BULLET.format(type(projectile).__name__))
        self.game_objects.add(projectile)
        projectile.push_handlers(self)

    def despawn_game_objects(self, game_objects):
        for gob in game_objects:
            gob.despawn()
        self.game_objects -= game_objects

    def check_collisions(self):
        collisions = collider.aabb_collide(list(self.game_objects))
        for group in collisions:
            a, b = group
            a.collide(b, VECTOR_NULL, VECTOR_NULL)
            b.collide(a, VECTOR_NULL, VECTOR_NULL)

    @property
    def current_props(self):
        if self.active_section is not None:
            return self.active_section.props
        else:
            return set()

    @property
    def width(self):
        return world.constants['WIN_WIDTH'] * len(self.sections)

    @property
    def height(self):
        return world.constants['WIN_HEIGHT']

    @property
    def active_rect(self):
        return (self.offset.x - 100, 0,
            self.offset.x + world.constants['WIN_WIDTH'] + 100,
            world.constants['WIN_HEIGHT'])

    @property
    def left(self):
        return self.offset.x

    @property
    def right(self):
        return self.offset.x + world.constants['WIN_WIDTH']

    @property
    def bottom(self):
        return self.offset.y

    @property
    def top(self):
        return self.offset.y + world.constants['WIN_HEIGHT']

    def send_keys_to_hero(self, keys, pressed=None, released=None):
        if self.hero is not None:
            self.hero.fixSpeed(keys)
        if pressed is not None:
            self.hero.throw_pebble()

    def on_hero_moved(self, the_hero, position):
        if position.x < self.offset.x - 100:
            pass  ## log.info('Hero left to the left.')
        elif position.x > self.offset.x + world.constants['WIN_WIDTH'] + 10:
            ## log.info('Hero left to the right.')
            if self.right < self.width:
                if the_hero.status != 'knockback':
                    the_hero.send_effect('knockback')
                    self.target_scroll_speed *= 1.2
                    the_hero.max_speed *= 1.2
            else:
                self.dispatch_event('on_end_stage')

    def on_emit(self, projectile):
        self.spawn_projectile(projectile)

    def on_object_moved(self, obj, position):
        if obj.despawn_on_exit:
            if obj.right <= self.left:  ## or obj.left >= self.right
                self.despawn(obj)
            elif obj.bottom >= self.top or obj.top <= self.bottom:
                self.despawn(obj)

    def despawn(self, obj):
        self.despawned_objects.add(obj)
        log.debug('Despawning {}'.format(type(obj).__name__))

    def update_progress_ball(self):
        self.progress_ball.x = min(624, int(624 * self.hero.x / self.width))
开发者ID:skunkfrukt,项目名称:miniature-nemesis,代码行数:104,代码来源:stage.py


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