level names
This commit is contained in:
parent
14e7c15326
commit
87bfda98ab
|
@ -11,6 +11,11 @@ struct LevelBin {
|
|||
uint8_t data[];
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct LevelBinNamed {
|
||||
struct LevelBin *bin;
|
||||
char *name;
|
||||
};
|
||||
|
||||
struct Level {
|
||||
int width, height, size, id;
|
||||
uint8_t *data;
|
||||
|
|
15
src/level.c
15
src/level.c
|
@ -12,8 +12,11 @@ static struct Level level;
|
|||
extern bopti_image_t bimg_tileset;
|
||||
|
||||
extern struct LevelBin kble_test, kble_burn, kble_bounce;
|
||||
static const struct LevelBin *levels[] = {&kble_test, &kble_burn, &kble_bounce,
|
||||
NULL};
|
||||
static const struct LevelBinNamed levels[] = {
|
||||
{&kble_test, "gentle introduction"},
|
||||
{&kble_burn, "these are rare"},
|
||||
{&kble_bounce, "deceptive road"},
|
||||
{NULL, NULL}};
|
||||
|
||||
static void level_free(void);
|
||||
|
||||
|
@ -34,7 +37,7 @@ level_deinit(void)
|
|||
void
|
||||
level_load(int id)
|
||||
{
|
||||
const struct LevelBin *const b = levels[id];
|
||||
const struct LevelBin *const b = levels[id].bin;
|
||||
int i = b->width * b->height;
|
||||
level_free();
|
||||
level.width = b->width;
|
||||
|
@ -58,7 +61,7 @@ level_reload(void)
|
|||
void
|
||||
level_next(void)
|
||||
{
|
||||
if (levels[level.id + 1] != NULL)
|
||||
if (levels[level.id + 1].bin != NULL)
|
||||
level_load(level.id + 1);
|
||||
else
|
||||
level_reload();
|
||||
|
@ -105,6 +108,10 @@ level_draw(void)
|
|||
vd->img_y, TILE_SIZE, TILE_SIZE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* level name */
|
||||
dprint_opt(DWIDTH - 2, DHEIGHT - 2, C_WHITE, C_BLACK, DTEXT_RIGHT,
|
||||
DTEXT_BOTTOM, "%s", levels[level.id].name);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in New Issue