Move animation data to config.h

This commit is contained in:
Joseph Ferano 2023-10-27 16:57:40 +07:00
parent 064963c685
commit da6631ee32
2 changed files with 52 additions and 49 deletions

51
config.h Normal file
View File

@ -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,
};

50
main.c
View File

@ -5,10 +5,10 @@
#include <GLFW/glfw3.h>
#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);