From 8126658a4339802fe040fb7be368711b533033cd Mon Sep 17 00:00:00 2001 From: kdx Date: Tue, 21 Mar 2023 22:19:31 +0100 Subject: display level names --- res/font.png | Bin 1490 -> 2359 bytes src/game.c | 4 ++++ src/game.h | 1 + src/main.c | 2 +- src/map.c | 10 ++++++++++ src/map.h | 1 + 6 files changed, 17 insertions(+), 1 deletion(-) diff --git a/res/font.png b/res/font.png index 929528d..dd796e3 100644 Binary files a/res/font.png and b/res/font.png differ diff --git a/src/game.c b/src/game.c index 31ac01b..40319d5 100644 --- a/src/game.c +++ b/src/game.c @@ -41,6 +41,7 @@ game_update(Game *this) if (e->type != ET_NONE && e->update != NULL) e->update(e, this); } + this->show_ui -= (this->show_ui > 0); } void @@ -52,12 +53,15 @@ game_draw(Game *this) if (e->type != ET_NONE && e->draw != NULL) e->draw(e, this); } + if (this->show_ui) + map_draw_ui(); } void game_restart_scene(Game *this) { memset(this->entities, 0, sizeof(this->entities)); + this->show_ui = 30; for (int y = 0; y < map_height(); y++) for (int x = 0; x < map_width(); x++) { const int dx = x * TSIZE + TSIZE / 2; diff --git a/src/game.h b/src/game.h index b8dae9f..2127fb9 100644 --- a/src/game.h +++ b/src/game.h @@ -8,6 +8,7 @@ typedef struct Game { bool queue_next_scene; int queue_restart_scene; int player_dir; + int show_ui; double spike_angle; Entity entities[MAX_ENTITIES]; } Game; diff --git a/src/main.c b/src/main.c index ff69d98..afc124f 100644 --- a/src/main.c +++ b/src/main.c @@ -32,8 +32,8 @@ int main(void) LZY_DrawBegin(); LZY_DrawSetColor(WHITE); LZY_DrawClear(); - background_draw(); game_draw(game); + background_draw(); LZY_DrawEnd(); } diff --git a/src/map.c b/src/map.c index dc0826d..c31eb66 100644 --- a/src/map.c +++ b/src/map.c @@ -70,8 +70,18 @@ draw_outline(int x, int y) void map_draw(void) { + LZY_DrawSetColor(BLACK); for (int y = 0; y < map_height(); y++) for (int x = 0; x < map_width(); x++) if (map_get(x, y) == 1) draw_outline(x, y); } + +void +map_draw_ui(void) +{ + const char *s = (char *)maps[1 + map_id]; + const int x = (DISPLAY_WIDTH - CHR_WIDTH * strlen(s)) / 2; + const int y = (DISPLAY_HEIGHT - CHR_HEIGHT) / 2; + LZY_DrawText(x, y, s); +} diff --git a/src/map.h b/src/map.h index b5bbfc6..d305d13 100644 --- a/src/map.h +++ b/src/map.h @@ -6,3 +6,4 @@ int map_height(void); int map_get(int x, int y); int map_get_px(int x, int y); void map_draw(void); +void map_draw_ui(void); -- cgit v1.2.3