def update(self): global big_ball_count balls = main_state.get_ball() zombie = main_state.get_zombie() if big_ball_count <= 0 and collide(zombie, self): balls.remove(self) game_world.remove_object(self) zombie.hp += 50
def find_ball(self): ball = main_state.get_ball() distance = (ball.x - self.x)**2 + (ball.y - self.y)**2 if distance < (PIXEL_PER_METER * 10)**2: self.dir = math.atan2(ball.y - self.y, ball.x - self.x) return BehaviorTree.SUCCESS else: self.speed = 0 return BehaviorTree.FAIL
def find_ball(self): balls = main_state.get_ball() for ball in balls: distance = (ball.x - self.x)**2 + (ball.y - self.y)**2 if distance < (PIXEL_PER_METER * 5)**2: self.dir = math.atan2(ball.y - self.y, ball.x - self.x) return BehaviorTree.SUCCESS else: return BehaviorTree.FAIL
def find_ball(self): balls = main_state.get_ball() if(len(balls) > 5): self.dir = math.atan2(balls[5].y - self.y, balls[5].x - self.x) return BehaviorTree.SUCCESS elif(len(balls) > 0): self.dir = math.atan2(balls[0].y - self.y, balls[0].x - self.x) return BehaviorTree.SUCCESS else: return BehaviorTree.FAIL
def find_ball(self): balls = main_state.get_ball() min_dis = 10000 min_ball = balls[0] for ball in balls: distance = (ball.x - self.x)**2 + (ball.y - self.y)**2 if min_dis**2 > distance and distance < (PIXEL_PER_METER * 5)**2: print('hi') min_dis = distance min_ball = ball distance = (min_ball.x - self.x)**2 + (min_ball.y - self.y)**2 if distance < (PIXEL_PER_METER * 5)**2: self.dir = math.atan2(min_ball.y - self.y, min_ball.x - self.x) return BehaviorTree.SUCCESS else: self.speed = 0 return BehaviorTree.FAIL