Restructure things for yaml config management
2
Makefile
@ -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
|
||||
|
8
assets/character_sprites.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
animations:
|
||||
- name: run_cycle
|
||||
x_pos: 0
|
||||
y_pos: 0
|
||||
rows: 1
|
||||
cols: 8
|
||||
width: 384
|
||||
height: 48
|
BIN
assets/idle.png
Before Width: | Height: | Size: 1.4 KiB |
BIN
assets/jump.png
Before Width: | Height: | Size: 1021 B |
BIN
assets/land.png
Before Width: | Height: | Size: 1.5 KiB |
BIN
assets/run.png
Before Width: | Height: | Size: 3.2 KiB |
BIN
assets/walk.png
Before Width: | Height: | Size: 2.4 KiB |
BIN
imports/sprites/player/run_cycle/1.png
Normal file
After Width: | Height: | Size: 680 B |
BIN
imports/sprites/player/run_cycle/2.png
Normal file
After Width: | Height: | Size: 669 B |
BIN
imports/sprites/player/run_cycle/3.png
Normal file
After Width: | Height: | Size: 650 B |
BIN
imports/sprites/player/run_cycle/4.png
Normal file
After Width: | Height: | Size: 567 B |
BIN
imports/sprites/player/run_cycle/5.png
Normal file
After Width: | Height: | Size: 665 B |
BIN
imports/sprites/player/run_cycle/6.png
Normal file
After Width: | Height: | Size: 699 B |
BIN
imports/sprites/player/run_cycle/7.png
Normal file
After Width: | Height: | Size: 690 B |
BIN
imports/sprites/player/run_cycle/8.png
Normal file
After Width: | Height: | Size: 532 B |
10
lib.h
@ -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
@ -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
|
||||
|
||||
|
@ -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,
|
||||
|