import numpy as np import glob2 import pygame import random RECT_SIZE = 50 class Package: def __init__(self, window): self.window = window self.length = np.random.randint(1, 3) * RECT_SIZE -1 self.width = RECT_SIZE-1 self.color = list(np.random.choice(range(256), size=3)) self.x = 1251 self.y = 351 # self.mark = random.choice(['fragile', 'dont turn around', 'keep dry', 'glass']) self.mark_image = self.get_marking_photo() self.block = pygame.Rect(self.x, self.y, self.width, self.length) def get_marking_photo(self): file_path_type = ["resources/package_markings/*.jpg"] images = glob2.glob(random.choice(file_path_type)) random_image = random.choice(images) print(random_image) return random_image def draw(self): pygame.draw.rect(self.window, self.color, self.block) pygame.display.flip()