-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsupport.py
More file actions
26 lines (20 loc) · 797 Bytes
/
support.py
File metadata and controls
26 lines (20 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from os import walk, path
import pygame
def import_folder(folder_path):
surface_list = []
base_path = path.dirname(path.abspath(__file__))
for _, __, img_files in walk(path.join(base_path, folder_path)):
for image in img_files:
full_path = path.join(base_path, folder_path, image)
image_surf = pygame.image.load(full_path).convert_alpha()
surface_list.append(image_surf)
return surface_list
def import_folder_dict(folder_path):
surface_dict = {}
base_path = path.dirname(path.abspath(__file__))
for _, __, img_files in walk(path.join(base_path, folder_path)):
for image in img_files:
full_path = path.join(base_path, folder_path, image)
image_surf = pygame.image.load(full_path).convert_alpha()
surface_dict[image.split('.')[0]] = image_surf
return surface_dict