aboutsummaryrefslogtreecommitdiff
path: root/src/util.py
diff options
context:
space:
mode:
authoromagdy7 <omar.professional8777@gmail.com>2023-04-19 02:09:53 +0200
committeromagdy7 <omar.professional8777@gmail.com>2023-04-19 02:09:53 +0200
commit6c43e3b3ab77ec0c3c57763178723a50e4dcac52 (patch)
treecbd4ce1a6ce900c1178c25f2dc6760e637aea71c /src/util.py
parent5cb37cd7aac7fab72b04061de6dfd5f2f5f254fa (diff)
downloadMacpan-6c43e3b3ab77ec0c3c57763178723a50e4dcac52.tar.xz
Macpan-6c43e3b3ab77ec0c3c57763178723a50e4dcac52.zip
Added the ghost sprites to the game.
Diffstat (limited to 'src/util.py')
-rw-r--r--src/util.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/util.py b/src/util.py
new file mode 100644
index 0000000..66fecb4
--- /dev/null
+++ b/src/util.py
@@ -0,0 +1,28 @@
+from typing import List
+import pygame
+
+
+def get_sprites(sprite_sheet) -> List:
+ sheet_width, sheet_height = sprite_sheet.get_size()
+ sprite_width, sprite_height = 32, 32
+ rows = sheet_height // sprite_height
+ columns = sheet_width // sprite_width
+ sprites = []
+
+ for row in range(rows):
+ for col in range(columns):
+ x = col * sprite_width
+ y = row * sprite_height
+
+ # Create a new surface for the current sprite and blit it from the
+ # sprite sheet onto this new surface
+ new_sprite_surface = pygame.Surface(
+ (sprite_width, sprite_height), pygame.SRCALPHA)
+ new_sprite_surface.blit(
+ sprite_sheet, (0, 0), (x, y, x + sprite_width, y + sprite_height))
+
+ # Add this new surface to our list of sprites
+ sprites.append(new_sprite_surface)
+
+ return sprites
+