import os import pygame from display import Scaling DEBUG = os.getenv("DEBUG") class Images: surfaces = {} @staticmethod def reload_images(): __class__.surfaces = {} with open("assets/images.lst") as image_list_file: for line in image_list_file: name, *path = line.strip().split() filename = os.path.join(*path) if DEBUG: print(f"Loading images {name = }, {filename = }") image = pygame.image.load(filename) rgba = pygame.Surface.convert_alpha(image) scaled = pygame.transform.smoothscale_by(rgba, Scaling.factor) __class__.surfaces[name] = scaled return True @staticmethod def load_images(): if __class__.surfaces: return False return __class__.reload_images()