level disaïgne & bugfix

This commit is contained in:
KikooDX 2021-11-11 18:31:29 +01:00
parent 44a944c00c
commit 1beb63ad41
4 changed files with 11 additions and 3 deletions

View File

@ -25,6 +25,7 @@ set(SOURCES
set(LEVELS
lvl/0.kble
lvl/1.kble
lvl/2.kble
)

BIN
lvl/1.kble Normal file

Binary file not shown.

6
sle.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
# https://sr.ht/~kikoodx/sle
sle -tile-width 16 -tile-height 16 -level-width 25 -level-height 14 \
-editor-width 396 -editor-height 224 -editor-off-x -2 -editor-off-y 0 \
-editor-bg-color '#000000' -picker-bg-color '#000005' \
-tileset res/tileset.png $@

View File

@ -10,8 +10,9 @@
static struct Level self;
extern struct LevelBin lvl_0;
extern struct LevelBin lvl_1;
extern struct LevelBin lvl_2;
static const struct LevelBin *levels[] = {&lvl_0, &lvl_2, NULL};
static const struct LevelBin *levels[] = {&lvl_0, &lvl_1, &lvl_2, NULL};
void
level_load(int id)
@ -22,7 +23,7 @@ level_load(int id)
self.height = s->height;
self.size = i;
self.data = malloc(i);
self.id = 0;
self.id = id;
while (i-- > 0)
self.data[i] = s->data[i];
player_init(level_find(TILE_PLAYER));
@ -38,7 +39,7 @@ level_reload(void)
void
level_next(void)
{
if (levels[self.id + 1])
if (levels[self.id + 1] != NULL)
level_load(self.id + 1);
else
level_reload();