summaryrefslogtreecommitdiff
path: root/Week1-Pacman/src/resources.c
diff options
context:
space:
mode:
authorBoredGuy <osome3717@gmail.com>2025-01-15 18:12:03 +0300
committerBoredGuy <osome3717@gmail.com>2025-01-15 18:12:03 +0300
commit6a6f7be378bee10679e9e1ea61a70b00b4731589 (patch)
tree8017237147d72e455d6479734579df39eefd2853 /Week1-Pacman/src/resources.c
parent5f7e0d8cf88d0adb9739e2cc7e26ba26243975f8 (diff)
Scuffed Resource SystemHEADmaster
I am super proud of this one TBH
Diffstat (limited to 'Week1-Pacman/src/resources.c')
-rw-r--r--Week1-Pacman/src/resources.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/Week1-Pacman/src/resources.c b/Week1-Pacman/src/resources.c
new file mode 100644
index 0000000..71f02aa
--- /dev/null
+++ b/Week1-Pacman/src/resources.c
@@ -0,0 +1,30 @@
+#include <SDL2/SDL_image.h>
+#include "resources.h"
+
+SDL_Texture* character_spritesheet;
+SDL_Texture* map_texture;
+
+SDL_Texture* load_texture(struct demo* demo, const char* image_name) {
+ SDL_Texture* texture =
+ IMG_LoadTexture(demo->ren, image_name);
+
+ if(texture == NULL) {
+ printf("Failed to load textue %s, error: %s, exitting!",
+ image_name, IMG_GetError());
+ exit(1);
+ }
+
+ return texture;
+}
+
+void load_resources(struct demo* demo) {
+ if(!character_spritesheet) {
+ character_spritesheet =
+ load_texture(demo, "assets/Sprites/sprites.png");
+ }
+
+ if(!map_texture) {
+ map_texture =
+ load_texture(demo, "assets/Sprites/Tileset.png");
+ }
+}