From 6a6f7be378bee10679e9e1ea61a70b00b4731589 Mon Sep 17 00:00:00 2001 From: BoredGuy Date: Wed, 15 Jan 2025 18:12:03 +0300 Subject: Scuffed Resource System I am super proud of this one TBH --- Week1-Pacman/src/resources.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Week1-Pacman/src/resources.c (limited to 'Week1-Pacman/src/resources.c') 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 +#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"); + } +} -- cgit v1.2.3