Add top bar game UI

This commit is contained in:
2023-12-28 09:47:55 +01:00
parent 0d09ffd67d
commit 118f7f9d93
6 changed files with 99 additions and 6 deletions

View File

@@ -280,6 +280,12 @@ void update(float dt, void *userData) {
}
}
static void drawOverScreen(Color c) {
i32 width = GetScreenWidth();
i32 height = GetScreenHeight();
DrawRectangle(0, 0, width, height, c);
}
static void renderGame(Game *game, float dt) {
ClearBackground(RAYWHITE);
BeginMode2D(game->camera);
@@ -300,13 +306,48 @@ static void renderGame(Game *game, float dt) {
EndMode2D();
}
static void drawOverScreen(Color c) {
// UI
i32 width = GetScreenWidth();
i32 height = GetScreenHeight();
bzUIBegin(UI, width, height);
bzUISetParentLayout(UI, (BzUILayout) {
.type = BZ_UI_LAYOUT_FLEX_BOX,
.flags = BZ_UI_FLEX_DIR_COLUMN |
BZ_UI_FLEX_JUSTIFY_SPACE_BETWEEN |
BZ_UI_FLEX_ALIGN_CENTER
});
// top bar
f32 topBarHeight = 0.05f;
BzUINode *topBar = uiPushDivParentPercentage(1.0f, topBarHeight);
bzUISetParentLayout(UI, (BzUILayout) {
.type = BZ_UI_LAYOUT_FLEX_BOX,
.flags = BZ_UI_FLEX_DIR_ROW |
BZ_UI_FLEX_ALIGN_CENTER |
BZ_UI_FLEX_JUSTIFY_START
});
Color topBarBG = {0, 0, 0, 50};
bzUISetBackgroundStyle(UI, topBar, (BzUIBackgroundStyle) {
.normal = topBarBG,
.hover = topBarBG,
.active = topBarBG,
});
BzTileset *tileset = &game->tileset;
Rectangle woodRec = bzTilesetGetTileRegion(tileset, getEntityTile(ENTITY_WOOD));
Rectangle stoneRec = bzTilesetGetTileRegion(tileset, getEntityTile(ENTITY_STONE));
Rectangle goldRec = bzTilesetGetTileRegion(tileset, getEntityTile(ENTITY_GOLD));
Rectangle popRec = bzTilesetGetTileRegion(tileset, getEntityTile(ENTITY_POP));
uiGameResCount(100, -1, woodRec, tileset->tiles);
uiGameResCount(100, -1, stoneRec, tileset->tiles);
uiGameResCount(100, -1, goldRec, tileset->tiles);
uiGameResCount(25, 100, popRec, tileset->tiles);
bzUIPopParent(UI);
bzUIEnd(UI);
DrawRectangle(0, 0, width, height, c);
}
static void renderMainMenu(Game *game, float dt) {
i32 width = GetScreenWidth();
i32 height = GetScreenHeight();