initial prototype

This commit is contained in:
SowinskiBraeden committed 2023-05-22 13:00:02 -07:00
commit c7439e4057
12 files changed
+125

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env python3.11
from pygame.image import load
from pygame import Surface
import os
def load_image(filename: str) -> Surface:
if '.' in filename and filename.split('.')[1] not in ['png', 'jpg', 'jpeg']:
raise Exception(f'Invalid filename: must be of filetype \'.png\' \'.jpg\' or \'.jpeg\' not of .{filename.split(".")[1]}')
cwd = os.getcwd()
dirName = '' if cwd.endswith('formula2D') else '/formula2D'
path = f'{cwd}{dirName}/resources/{filename}'
if not os.path.isfile(path):
raise Exception(f'Filepath not found: \'{path}\' cannot be found')
return load(path)