From da6631ee32f024a9a60b667ca9ef1dee85ea1b37 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Fri, 27 Oct 2023 16:57:40 +0700 Subject: [PATCH] Move animation data to config.h --- config.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ main.c | 50 +------------------------------------------------- 2 files changed, 52 insertions(+), 49 deletions(-) create mode 100644 config.h diff --git a/config.h b/config.h new file mode 100644 index 0000000..063f762 --- /dev/null +++ b/config.h @@ -0,0 +1,51 @@ +#pragma once + +#include "animation.h" +#include "lib.h" + +SpriteSheet spriteSheet = { + .name = "player", + .animCount = 4, + .width = 512, + .height = 512, +}; + +Animation idle = { + .name = "idle", + .posX = 0, + .posY = 0, + .rows = 1, + .cols = 10, + .width = 48, + .height = 48, +}; + +Animation run = { + .name = "run", + .posX = 0, + .posY = 48 * 3, + .rows = 1, + .cols = 8, + .width = 48, + .height = 48, +}; + +Animation jump = { + .name = "jump", + .posX = 0, + .posY = 48, + .rows = 1, + .cols = 3, + .width = 48, + .height = 48, +}; + +Animation land = { + .name = "land", + .posX = 0, + .posY = 48 * 2, + .rows = 1, + .cols = 9, + .width = 48, + .height = 48, +}; diff --git a/main.c b/main.c index 35bffb2..ab45e6d 100644 --- a/main.c +++ b/main.c @@ -5,10 +5,10 @@ #include #include "cglm/cglm.h" #include "lib.h" +#include "config.h" #include "stb_image.h" #include "rendering.h" #include "animation.h" -#include "libcyaml/include/cyaml/cyaml.h" #define PI 3.14159f @@ -143,54 +143,6 @@ int main(void) { return -1; } - SpriteSheet spriteSheet = { - .name = "player", - .imgData = data, - .animCount = 4, - .width = width, - .height = height, - }; - - Animation idle = { - .name = "idle", - .posX = 0, - .posY = 0, - .rows = 1, - .cols = 10, - .width = 48, - .height = 48, - }; - - Animation run = { - .name = "run", - .posX = 0, - .posY = 48 * 3, - .rows = 1, - .cols = 8, - .width = 48, - .height = 48, - }; - - Animation jump = { - .name = "jump", - .posX = 0, - .posY = 48, - .rows = 1, - .cols = 3, - .width = 48, - .height = 48, - }; - - Animation land = { - .name = "land", - .posX = 0, - .posY = 48 * 2, - .rows = 1, - .cols = 9, - .width = 48, - .height = 48, - }; - Animation playerAnims[4] = {idle, run, jump, land}; glGenTextures(1, &textureID);