fellow gameurs and gameuses

This commit is contained in:
KikooDX 2021-11-17 15:43:38 +01:00
parent 07703bbb76
commit 4613a7df8f
3 changed files with 17 additions and 12 deletions

View File

@ -11,7 +11,7 @@ run: ray
out/levels_bin.h:
mkdir -p out
cembed -o out/levels_bin.h lvl/*.kble
cembed -o out/levels_bin.h -t levels lvl/*.kble
format:
clang-format -style=file -i src/**.c inc/**.h

@ -1 +1 @@
Subproject commit edc6fb1c5bc52a3b4f7c735980576cf44543b4de
Subproject commit 2403783b3a7574828815aa9be9b541342d4684fa

View File

@ -7,21 +7,20 @@
#include "raygint/display.h"
#include "tile.h"
#include "vec.h"
#include <stdio.h>
#include <stdlib.h>
static struct Level self;
static const struct LevelBin *levels[] = {
&lvl_0_kble, &lvl_1_kble, &lvl_2_kble, &lvl_3_kble,
&lvl_4_kble, &lvl_5_kble, &lvl_6_kble, &lvl_7_kble,
&lvl_8_kble, &lvl_9_kble, &lvl_end_kble};
void
level_load(int id)
{
extern int end;
const struct LevelBin *s = levels[id];
#ifdef GINT
const struct LevelBin *s = levels[id].data;
#endif
#ifdef RAYLIB
s++;
const struct LevelBin *s = levels[id].data + 1;
#endif
int i = s->width * s->height;
self.width = s->width;
@ -33,7 +32,7 @@ level_load(int id)
self.data[i] = s->data[i];
player_init(level_find(TILE_PLAYER));
particles_init();
if (levels[self.id + 1] == NULL)
if (levels[self.id + 1].data == NULL)
end = 1;
}
@ -46,7 +45,7 @@ level_reload(void)
void
level_next(void)
{
if (levels[self.id + 1] != NULL)
if (levels[self.id + 1].data != NULL)
level_load(self.id + 1);
else
level_reload();
@ -94,10 +93,16 @@ void
level_draw(void)
{
const struct Vec off = camera_offset();
Color colors[TILE_OOB] = {0};
colors[TILE_SOLID] = C_WHITE;
colors[TILE_SHATTERED] = GRAY;
colors[TILE_SPIKE_L] = SKYBLUE;
colors[TILE_SPIKE_R] = SKYBLUE;
colors[TILE_SPIKE_U] = SKYBLUE;
colors[TILE_SPIKE_D] = SKYBLUE;
int i;
int x = 0;
int y = 0;
for (i = 0; i < self.size; i++) {
const int tile = self.data[i];
if (tile && tile != TILE_THUNDER) {
@ -105,7 +110,7 @@ level_draw(void)
const int sy1 = y * TILE_SIZE + off.y;
const int sx2 = sx1 + TILE_SIZE - 1;
const int sy2 = sy1 + TILE_SIZE - 1;
drect(sx1, sy1, sx2, sy2, C_WHITE);
drect(sx1, sy1, sx2, sy2, colors[tile]);
}
if (++x >= self.width) {