Restructure things for yaml config management

This commit is contained in:
Joseph Ferano 2023-10-16 18:22:31 +07:00
parent 286eca58d6
commit 7ecc075c5b
18 changed files with 24 additions and 2 deletions

View File

@ -12,7 +12,7 @@ build: clean
.PHONY: texturepacker
texturepacker:
$(CC) $(CFLAGS) $(LDLIBS) $(INCLUDES) $(OBJECTS) tools/texturepacker.c -o texturepacker
$(CC) $(CFLAGS) -lSDL2 -lm -lcyaml -L objs/ $(INCLUDES) tools/texturepacker.c -o texturepacker
.PHONY: run
run: build

View File

@ -0,0 +1,8 @@
animations:
- name: run_cycle
x_pos: 0
y_pos: 0
rows: 1
cols: 8
width: 384
height: 48

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1021 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 532 B

10
lib.h
View File

@ -17,6 +17,16 @@ typedef char byte;
typedef ptrdiff_t size;
typedef size_t usize;
typedef struct Animation {
char* name;
u16 x_pos;
u16 y_pos;
u16 rows;
u16 cols;
u16 width;
u16 height;
} SpriteSheet;
void checkCode(int code, char* errorMsg) {
if (code < 0) {
fprintf(stderr, "Application Error %i: %s\n", code, errorMsg);

1
main.c
View File

@ -6,6 +6,7 @@
#include "cglm/cglm.h"
#include "lib.h"
#include "stb_image.h"
#include "libcyaml/include/cyaml/cyaml.h"
#define PI 3.14159f

View File

@ -13,6 +13,8 @@
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
#include "../libs/libcyaml/include/cyaml/cyaml.h"
typedef struct image_t {
char* filename;
unsigned char* image_data;
@ -219,7 +221,8 @@ int main(int argc, char* argv[]) {
//-------------------------------------
tex_rect_t* tex_rects = calloc(image_count, sizeof(tex_rect_t));
int size, totalh, maxw;
int max = pack_textures(images, tex_rects, image_count, &size, &totalh, &maxw);
// int max = pack_textures(images, tex_rects, image_count, &size, &totalh, &maxw);
pack_textures(images, tex_rects, image_count, &size, &totalh, &maxw);
//-------------------------------------
// Now load the data into memory, for now, let's just load all images in one go,