diff --git a/.gitignore b/.gitignore index 1de5659..dbd1181 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -target \ No newline at end of file +target +__pycache__ +*.pyc \ No newline at end of file diff --git a/src/main/python/preponderous/graphik/graphik.py b/src/main/python/preponderous/graphik/graphik.py index 331cc91..9a2d8eb 100644 --- a/src/main/python/preponderous/graphik/graphik.py +++ b/src/main/python/preponderous/graphik/graphik.py @@ -43,4 +43,15 @@ def drawButton(self, xpos, ypos, width, height, colorBox, colorText, sizeText, t if (xpos + width > mouse[0] > xpos and ypos + height > mouse[1] > ypos): click = pygame.mouse.get_pressed() if click[0] == 1: - function() \ No newline at end of file + function() + + def drawImage(self, filePath, xpos, ypos, width, height): + try: + image = pygame.image.load(filePath) + image = pygame.transform.scale(image, (width, height)) + self.gameDisplay.blit(image, (xpos, ypos)) + except FileNotFoundError as e: + # Preserve the original exception and chain it + raise FileNotFoundError(f"Failed to load image from '{filePath}': {e}") from e + except pygame.error as e: + raise pygame.error(f"Failed to load image from '{filePath}': {e}") from e \ No newline at end of file