def Attack_Player(self): player = main_state.get_player() if self.Attack_count >= 30: self.Attack_sound.play() self.Attack_count = -30 player.hp -= 10 player.collideWithEnemy = True self.Attack_count += 1
def find_player(self): player = main_state.get_player() distance = (player.x - self.x)**2 + (player.y - self.y)**2 if distance < (PIXEL_PER_METER * 10)**2 and player.hide == False: self.dir = math.atan2(player.y - self.y, player.x - self.x) return BehaviorTree.SUCCESS else: self.speed = 0 return BehaviorTree.FAIL
def update(self): if self.dir is UP: self.y += BULLET_SPEED_PPS * game_framework.frame_time elif self.dir is DOWN: self.y -= BULLET_SPEED_PPS * game_framework.frame_time elif self.dir is RIGHT: self.x += BULLET_SPEED_PPS * game_framework.frame_time elif self.dir is LEFT: self.x -= BULLET_SPEED_PPS * game_framework.frame_time if (self.shoot_point[0] - self.x)**2 + (self.shoot_point[1] - self.y)**2 > self.range**2: player = main_state.get_player() player.arms[player.current_arm].bullets.remove(self) game_world.remove_object(self)