コード例 #1
0
    def __init__(self, number, color, center, radius, velocity):
        w_size                  = globals.window_size()
        self.number             = number
        self.color              = color
        self.start_color        = color

        self.position     = Coordinate(center)
        self.radius       = Coordinate((radius,radius))
        self.velocity     = Coordinate(velocity)
        self.edges        = calculate.edge_values(self.position.rel, self.radius.rel)
        self.walls_hit    = calculate.walls_hit(self.edges)
        self.text_position= calculate.ball_text_position(str(self.number), globals.font(), self.position.abs, w_size)
コード例 #2
0
 def _move_balls(self):
     for ball in self.balls:
         ball.position   = Coordinate(calculate.new_position(ball.position.rel, ball.velocity.rel))
         ball.edges      = calculate.edge_values(ball.position.rel, ball.radius.rel)
         ball.walls_hit  = calculate.walls_hit(ball.edges)
         ball.velocity   = Coordinate(calculate.velocity_after_wall_collision(ball.velocity.rel, ball.walls_hit))
コード例 #3
0
 def _new_ball_not_in_wall(self, ball):
     edges = calculate.edge_values(ball.position.rel, ball.radius.rel)
     walls_hit = calculate.walls_hit(edges)
     if walls_hit == '': return True
     else:               return False