本文整理汇总了Python中weapon.Weapon.attack_animation方法的典型用法代码示例。如果您正苦于以下问题:Python Weapon.attack_animation方法的具体用法?Python Weapon.attack_animation怎么用?Python Weapon.attack_animation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weapon.Weapon
的用法示例。
在下文中一共展示了Weapon.attack_animation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Player
# 需要导入模块: from weapon import Weapon [as 别名]
# 或者: from weapon.Weapon import attack_animation [as 别名]
#.........这里部分代码省略.........
def status_bar(self):
""" Show the bars for health and stamina """
x = 0
if self.num == 0:
x = 10 # bar for first player
else:
x = 614 # bar for second player
health_bar = StatusBar(self.screen, x, 10, (228,7,7))
stamina_bar = StatusBar(self.screen, x, 40, (55,204,55))
health_bar.update(self.current_health / self.total_health)
stamina_bar.update(self.current_stamina / self.total_stamina)
# -- Attacks Method --
def sufficient_stamina(self, num):
""" Determine if the player has enought stamina to use the attack """
cost = 0
if num == 0: # Melee attack
cost = self.melee_cost
elif num == 1: # Laser attack
cost = self.laser_cost
return self.current_stamina >= cost
def create_sword(self):
""" Create the melee weapon """
self.weapon = Weapon()
self.weapon.player = self
self.weapon.enemy = self.enemy
self.weapon_sprite.add(self.weapon)
def melee_attack(self):
self.weapon.attack_animation()
def range_attack(self):
self.current_stamina -= self.laser_cost
# Create the long range attack
laser = Laser(BLUE_LASER)
laser.rect.x = self.rect.x + 20
laser.starting_x = self.rect.x
laser.rect.y = self.rect.y + self.rect.height / 2
laser.player = self
laser.enemy = self.enemy
laser.direction = self.direction
return laser
def damage(self, damage):
""" Handles the damage that the player takes """
self.current_health -= damage
if self.current_health <= 0:
self.current_health = 0
self.status_bar()
self.alive = False
# -- Movement Method --
def jumping_speed(self):
""" adjust the movement speed
if the player jumps it's movement speed is decreased
when the player lands it's movement speed is increased
"""
if self.on_ground:
self.movement_speed = 10
if self.change_x > 0:
self.go_right()