Ninja-Jump-and-run/scripts/utils.py

18 lines
444 B
Python
Raw Permalink Normal View History

2026-02-06 17:51:57 +00:00
import pygame
import os
BASE_IMG_PATH: str = 'data/images/'
def load_image(path: str) -> pygame.Surface:
2026-03-04 15:50:44 +00:00
img = pygame.image.load(BASE_IMG_PATH + path).convert()
img.set_colorkey((0, 0, 0))
return img
def load_images(path: str) -> list[pygame.Surface]:
images: list[pygame.Surface] = []
2026-03-04 15:50:44 +00:00
for img_name in sorted(os.listdir(BASE_IMG_PATH + path)):
images.append(load_image(path + '/' + img_name))
2026-02-06 17:51:57 +00:00
return images