Beispiel #1
0
    def set_pool_balls(self):
        counter = [0, 0]
        coord_shift = np.array([
            math.sin(math.radians(60)) * config.ball_radius * 2,
            -config.ball_radius
        ])
        initial_place = config.ball_starting_place_ratio * config.resolution

        self.create_white_ball()
        ball_placement_sequence = list(range(1, config.total_ball_num))
        random.shuffle(ball_placement_sequence)

        for i in ball_placement_sequence:
            ball_iteration = ball.BallSprite(i)
            remaining_ball = ball.BallSprite(i)
            ball_iteration.move_to(initial_place + coord_shift * counter)
            if counter[1] == counter[0]:
                counter[0] += 1
                counter[1] = -counter[0]
            else:
                counter[1] += 2
            self.balls.add(ball_iteration)
            self.remaining_balls.add(remaining_ball)

        self.all_sprites.add(self.balls)
Beispiel #2
0
    def set_pool_balls(self):
        counter = [0, 0]
        # coord_shift = np.array([math.sin(math.radians(60)) * config.ball_radius *
        #                         2, -config.ball_radius])
        # initial_place = config.ball_starting_place_ratio * config.resolution

        self.create_white_ball()
        # randomizes the sequence of balls on the table
        ball_placement_sequence = list(range(1, config.total_ball_num))
        random.shuffle(ball_placement_sequence)

        self.first_ball=random.randint(2,8)
        while True:
            self.second_ball=random.randint(2,8)
            if(self.second_ball!=self.first_ball):
                break
        
        for i in [self.first_ball,self.second_ball,9]:
            ball_iteration = ball.BallSprite(i)
            ball_iteration.move_to([random.randint(80,920),random.randint(80,420)])
            # if counter[1] == counter[0]:
            #     counter[0] += 1
            #     counter[1] = -counter[0]
            # else:
            #     counter[1] += 2
            self.balls.add(ball_iteration)

        self.all_sprites.add(self.balls)
Beispiel #3
0
    def create_white_ball(self):
        self.create_white_ball = ball.BallSprite(0)
        ball_pos = config.white_ball_initial_pos
        while check_if_ball_touches_ball(ball_pos, 0, self.balls):
            ball_pos = [random.randint(int(config.table_margin +  config.ball_radius + config.hole_radius),int(config.white_ball_initial_pos[0])),
                        random.randint(int(config.table_margin +  config.ball_radius + config.hole_radius),int(config.resolution[1] - config.ball_radius - config.hole_radius))]

        self.white_ball.move_to(ball.pos)
        self.balls.add(self.white_ball)
        self.all_sprites.add(self.white_ball)
Beispiel #4
0
    def set_pool_balls(self, other_ball_pos):
        counter = [0, 0]
        coord_shift = np.array([
            math.sin(math.radians(60)) * config.ball_radius * 2,
            -config.ball_radius
        ])
        initial_place = other_ball_pos
        #print(initial_place)
        self.create_white_ball()
        # randomizes the sequence of balls on the table
        ball_placement_sequence = [1]

        for i in ball_placement_sequence:
            ball_iteration = ball.BallSprite(i)
            ball_iteration.move_to(initial_place)
            if counter[1] == counter[0]:
                counter[0] += 1
                counter[1] = -counter[0]
            else:
                counter[1] += 2
            #print(counter[1], counter[0])
            self.balls.append(ball_iteration)

        self.all_sprites.append(self.balls)
Beispiel #5
0
 def create_white_ball(self):
     self.white_ball = ball.BallSprite(0)
     #print(config.white_ball_initial_pos)
     ball_pos = config.white_ball_initial_pos  #sets the intial position of the white ball yoooooo ----- change this
     #print("ball pos:", str(ball_pos))
     #print(self.balls)
     while check_if_ball_touches_balls(ball_pos, 0,
                                       self.balls):  #moves bad ball?
         #print(ball_pos)
         #print("111111")
         ball_pos = [
             random.randint(
                 int(config.table_margin + config.ball_radius +
                     config.hole_radius),
                 int(config.white_ball_initial_pos[0])),
             random.randint(
                 int(config.table_margin + config.ball_radius +
                     config.hole_radius),
                 int(config.resolution[1] - config.ball_radius -
                     config.hole_radius))
         ]
     self.white_ball.move_to(ball_pos)
     self.balls.append(self.white_ball)
     self.all_sprites.append(self.white_ball)
Beispiel #6
0
 def create_white_ball(self):
     self.white_ball = ball.BallSprite(0)
     ball_pos = config.white_ball_initial_pos
     self.white_ball.move_to(ball_pos)
     self.balls.add(self.white_ball)
     self.all_sprites.add(self.white_ball)