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


Python Weapon.attack_animation方法代码示例

本文整理汇总了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()
开发者ID:jwj9627,项目名称:platform-fighting,代码行数:70,代码来源:player.py


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