Exemplo n.º 1
0
 def add_segment(self, car_x, car_y):
     if self.frame == self.segment_number:  # last segment is always the car's position
         self.segments_coo.append((car_x, car_y))
         return None
     medium_segment_length = (car_x - self.segments_coo[0][0]
                              ) // self.segment_number  # (Xf-Xi)/ n
     segment_x = self.segments_coo[-1][0] + Af.randint(
         int(medium_segment_length * 0.75), medium_segment_length)
     segment_y = self.segments_coo[-1][1] + Af.randint(
         10, 70) * self.last_segment_direction
     self.last_segment_direction *= -1  # invert next segment direction
     self.segments_coo.append((segment_x, segment_y))
Exemplo n.º 2
0
 def change_properties(self):
     self.segment_number = Af.randint(5, 7)
     self.internal_beam_radius = 2 * self.segment_number
     self.external_beam_radius = Af.get_fibonacci(self.segment_number)
     self.frame = 0
     self.segments_coo = [self.starting_point_coo]
     self.last_segment_direction = Af.choice([-1, 1])
Exemplo n.º 3
0
 def choose_image(self):
     self.folder = str(Af.randint(1, 4))
     if self.folder == "4":
         self.image = Af.load_image(f"obstacles/4/{Af.randint(1, 11)}.png")
     else:
         self.image = Af.load_image(f"obstacles/{self.folder}/1.png")
     self.hit_box = pygame.mask.from_surface(self.image)
     self.rect = self.image.get_rect()
Exemplo n.º 4
0
 def create_parts(self):
     dist_between_blocs = Af.randint(self.min_dist_between_blocs,
                                     self.max_dist_between_blocs)
     type_p = self.calculate_type_part()
     if self.first_parts:
         for i in range(Af.randint(self.min_parts, self.max_parts)):
             self.internal_list.append(
                 _part(
                     space_between_obstacles[-1] + dist_between_blocs +
                     i * self.dist_between_parts, type_p, self.y, i % 10))
         self.first_parts = False
         return 0
     if self.control_last():
         for i in range(Af.randint(self.min_parts, self.max_parts)):
             self.internal_list.append(
                 _part(
                     space_between_obstacles[-1] + dist_between_blocs +
                     i * self.dist_between_parts, type_p, self.y, i % 10))
         self.y = Af.choice(self.choices)
         return 0