From 5f7e0d8cf88d0adb9739e2cc7e26ba26243975f8 Mon Sep 17 00:00:00 2001 From: BoredGuy Date: Fri, 3 Jan 2025 11:38:13 +0300 Subject: Minor optimization Animations can now share a single texture --- Week1-Pacman/src/animation.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Week1-Pacman/src/animation.c') diff --git a/Week1-Pacman/src/animation.c b/Week1-Pacman/src/animation.c index 7e4bb57..50f5c6c 100644 --- a/Week1-Pacman/src/animation.c +++ b/Week1-Pacman/src/animation.c @@ -17,7 +17,11 @@ void init_animation(struct animation* animation, exit(1); } - animation->texture = IMG_LoadTexture(init->ren, init->spritesheet); + if(init->spritesheet_texture == NULL) { + animation->texture = IMG_LoadTexture(init->ren, init->spritesheet); + } else { + animation->texture = init->spritesheet_texture; + } if(animation->texture == NULL) { printf("Failed to load spritesheet %s, error: %s, exitting!\n", -- cgit v1.2.3