display level names

This commit is contained in:
kdx 2023-03-21 22:19:31 +01:00
parent d34c041657
commit 8126658a43
6 changed files with 17 additions and 1 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -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;

View File

@ -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;

View File

@ -32,8 +32,8 @@ int main(void)
LZY_DrawBegin();
LZY_DrawSetColor(WHITE);
LZY_DrawClear();
background_draw();
game_draw(game);
background_draw();
LZY_DrawEnd();
}

View File

@ -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);
}

View File

@ -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);