From 85adc89f53763b4390f7e51161a05ab394143152 Mon Sep 17 00:00:00 2001 From: Viljami Ilola <+@hix.fi> Date: Sat, 16 Mar 2024 11:11:56 +0200 Subject: drafting game components --- src/sliceitoff/images/__init__.py | 1 + src/sliceitoff/images/images.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/sliceitoff/images/__init__.py create mode 100644 src/sliceitoff/images/images.py (limited to 'src/sliceitoff/images') diff --git a/src/sliceitoff/images/__init__.py b/src/sliceitoff/images/__init__.py new file mode 100644 index 0000000..16d361a --- /dev/null +++ b/src/sliceitoff/images/__init__.py @@ -0,0 +1 @@ +from .images import images, load_images diff --git a/src/sliceitoff/images/images.py b/src/sliceitoff/images/images.py new file mode 100644 index 0000000..102ca0f --- /dev/null +++ b/src/sliceitoff/images/images.py @@ -0,0 +1,19 @@ +import os +import pygame + +DEBUG = os.getenv("DEBUG") + +images = {} + +def load_images(scale): + if not images: + 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) + images[name] = pygame.transform.smoothscale_by( + pygame.Surface.convert_alpha(image), + scale) -- cgit v1.2.3