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


Python Animation.render方法代码示例

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


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

示例1: Powerup

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import render [as 别名]
class Powerup(object):
    def __init__(self, i, j):
        global powerups
        init_powerups()
        self.i = i
        self.j = j
        self.timer = globals.pw_timer
        self.powerup = choice(powerups)
        index = powerups.index(self.powerup)
        player = globals.squares[i][j].owner.player_number-1
        self.animation = Animation(globals.pw_images[index][player])

    def update(self):
        self.timer -= globals.clock.get_time()
        if self.timer < 0:
            globals.powerups.remove(self)

        self.animation.update()

    def pickup(self, player):
        self.powerup(player)
        globals.powerups.remove(self)

    def render(self):
        self.animation.render(
            self.i * globals.square_size,
            self.j * globals.square_size,
        )
开发者ID:joaodelgado,项目名称:bomber,代码行数:30,代码来源:powerup.py

示例2: Bomb

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import render [as 别名]
class Bomb(object):
    def __init__(self, i, j, player):
        self.i = i
        self.j = j
        self.player = player
        self.timer = globals.b_timer
        self.animation = Animation(globals.b_images[player.player_number-1])

    def update(self):
        self.timer -= globals.clock.get_time()
        if self.timer < 0:
            self.explode()
        self.animation.update()

    def explode(self):
        self.remove()

        # rewrite for loops
        for i in range(
                max(0,
                    int(self.i - self.player.bomb_radious)),
                min(globals.squares_per_line,
                    int(self.i+1 + self.player.bomb_radious))):
            for j in range(
                    max(0,
                        int(self.j - self.player.bomb_radious)),
                    min(globals.squares_per_line,
                        int(self.j+1 + self.player.bomb_radious))):
                center = (self.i, self.j)
                square = (i, j)

                if utils.distance(center, square) <= self.player.bomb_radious:

                    # delete powerup in that square, if any
                    for powerup in globals.powerups:
                        if powerup.i == square[0] and \
                           powerup.j == square[1]:
                            globals.powerups.remove(powerup)
                            break

                    # delete bomb in that square, if any
                    for bomb in globals.bombs:
                        if bomb.i == square[0] and \
                           bomb.j == square[1]:
                            bomb.remove()
                            break

                    if globals.squares[i][j].owner != self.player:
                        globals.squares[i][j].change_owner(self.player)
                    globals.explosions.append(Explosion(i, j))

    def remove(self):
        globals.bombs.remove(self)
        self.player.current_bombs -= 1

    def render(self):
        self.animation.render(
            self.i * globals.square_size,
            self.j * globals.square_size,
        )
开发者ID:joaodelgado,项目名称:bomber,代码行数:62,代码来源:bomb.py


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