From 07703bbb760ac0370d09b9092dad03ae99840f6a Mon Sep 17 00:00:00 2001 From: KikooDX Date: Wed, 17 Nov 2021 15:14:03 +0100 Subject: [PATCH] game starts --- Makefile | 3 +++ inc/level.h | 13 +++++++------ raygint | 2 +- src/anim.c | 2 +- src/level.c | 3 +++ src/shatter.c | 1 - 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 251da88..370637b 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,9 @@ ray: clean format out/levels_bin.h cmake -B build . make -C build +run: ray + build/target + out/levels_bin.h: mkdir -p out cembed -o out/levels_bin.h lvl/*.kble diff --git a/inc/level.h b/inc/level.h index ce138b9..132aeb5 100644 --- a/inc/level.h +++ b/inc/level.h @@ -1,20 +1,21 @@ #pragma once #include "tile.h" #include "vec.h" +#include struct LevelBin { - unsigned char format; - unsigned char chunk_size; - unsigned short width; - unsigned short height; - unsigned char data[]; + uint8_t format; + uint8_t chunk_size; + uint16_t width; + uint16_t height; + uint8_t data[]; } __attribute__((__packed__)); struct Level { int width; int height; int size; - char *data; + uint8_t *data; int id; }; diff --git a/raygint b/raygint index 04cfbea..edc6fb1 160000 --- a/raygint +++ b/raygint @@ -1 +1 @@ -Subproject commit 04cfbeac77bbe097d94566c4c3f345336318aca5 +Subproject commit edc6fb1c5bc52a3b4f7c735980576cf44543b4de diff --git a/src/anim.c b/src/anim.c index 8506289..bf87607 100644 --- a/src/anim.c +++ b/src/anim.c @@ -13,7 +13,7 @@ anim_new(bopti_image_t *texture, int x, int y, int frame_width, anim.pos = VEC(x, y); #ifdef GINT anim.frame_dim = VEC(frame_width, texture->height); - anim.life_ini = frame_duration * texture->width * frame_width; + anim.life_ini = frame_duration * texture->width / frame_width; #endif #ifdef RAYLIB anim.frame_dim = VEC(frame_width, frame_width); diff --git a/src/level.c b/src/level.c index 4c92098..8102e10 100644 --- a/src/level.c +++ b/src/level.c @@ -20,6 +20,9 @@ level_load(int id) { extern int end; const struct LevelBin *s = levels[id]; +#ifdef RAYLIB + s++; +#endif int i = s->width * s->height; self.width = s->width; self.height = s->height; diff --git a/src/shatter.c b/src/shatter.c index 9ce633c..1292b7e 100644 --- a/src/shatter.c +++ b/src/shatter.c @@ -22,7 +22,6 @@ shatter(int x, int y) const int ax = (int)(x / TILE_SIZE) * TILE_SIZE; const int ay = (int)(y / TILE_SIZE) * TILE_SIZE; struct Anim p = anim_new(&bimg_shatter, ax, ay, TILE_SIZE, 2, false); - p.callback = callback; if (level_get_px(ax, ay) == TILE_SOLID && !particles_here(ax, ay)) particles_add(p);