本文整理汇总了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,
)
示例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,
)