def _check_for_overlaps(self): combos = itertools.combinations(self.balls, 2) self.ball_collisions = [(a.number,b.number) for (a,b) in combos if calculate.ball_collision(a.position.rel, a.radius.rel, b.position.rel, b.radius.rel)] self.balls_hit_other_ball = set([item for inner_iterable in self.ball_collisions for item in inner_iterable]) self.balls_hit_wall = set([ball.number for ball in self.balls if ball.walls_hit != ''])
def _new_ball_not_in_other_ball(self, new_ball, balls_so_far): for old_ball in balls_so_far: if calculate.ball_collision(old_ball.position.rel, old_ball.radius.rel, new_ball.position.rel, new_ball.radius.rel): return False return True