def __post_init__(self): """Randomize self.""" self.img = pygame.image.load(Images.get_path(r'flora.png')) if self.is_home: self.img = pygame.image.load(Images.get_path(r'home.png')) self.looks_like_home = True # Pick which color we are self.img_color = random.choice(range(0, 5)) color_file = Images.color_files[self.img_color] color_img = pygame.image.load(Images.get_path(color_file)) # Apply chosen color if not self.is_home: Images.color_image(self.img, color_img) # Size self.block_size = int(self.size_multiple * 32) self.img_scale = int(self.size / self.block_size) self.size_x = self.block_size * self.img_scale self.size_y = self.block_size * self.img_scale self.img = pygame.transform.scale(self.img, (int( self.size_x * self.img_cols), int(self.size_y * self.img_rows))) # Pick which variety we are. var_x = self.variety % self.img_cols var_y = self.variety % self.img_rows self.draw_area = pygame.Rect(var_x * self.block_size * self.img_scale, var_y * self.block_size * self.img_scale, self.block_size * self.img_scale, self.block_size * self.img_scale) self.logic() # Bootstrap our collision rect.
def __post_init__(self): """Load some images.""" self.images = [] for color in Images.color_files: color_img = pygame.image.load(Images.get_path(color)) horse = pygame.image.load(self.default) Images.color_image(base_image=horse, color_image=color_img) red_horse = pygame.transform.scale(horse, (int(self.size_x), int(self.size_y))) self.images += [red_horse] pygame.display.set_icon(self.images[0])
def __post_init__(self): """Size self.""" self.img = pygame.image.load(Images.get_path(r'firework.png')) # Size self.block_size = int(self.size_multiple * 32) self.img_scale = int(self.size / self.block_size) self.size_x = self.block_size * self.img_scale self.size_y = self.block_size * self.img_scale self.img_color = True color = random.choice(Images.color_files) color_img = pygame.image.load(Images.get_path(color)) self.img = Images.color_image(base_image=self.img, color_image=color_img) self.img = pygame.transform.scale(self.img, (int(self.size_x * self.img_cols), int(self.size_y * self.img_rows)))