fp: Integrate the icons
This commit is contained in:
+156
-24
@@ -2512,6 +2512,7 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
|
||||
// NOTE: Render player avatar HUD ==========================================
|
||||
Dqn_Rect player_avatar_rect = {};
|
||||
player_avatar_rect.pos = Dqn_V2_InitNx1(32.f);
|
||||
Dqn_V2 next_pos = {};
|
||||
{
|
||||
TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity());
|
||||
DQN_DEFER { TELY_Render_PopTransform(renderer); };
|
||||
@@ -2529,31 +2530,30 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
|
||||
|
||||
TELY_Render_PushFont(renderer, game->talkco_font);
|
||||
DQN_DEFER { TELY_Render_PopFont(renderer); };
|
||||
Dqn_V2 next_pos = Dqn_Rect_InterpolatedPoint(player_avatar_rect, Dqn_V2_InitNx2(1.f, 0));
|
||||
TELY_Render_TextF(renderer, next_pos, Dqn_V2_Zero, "Terry");
|
||||
|
||||
next_pos = Dqn_Rect_InterpolatedPoint(player_avatar_rect, Dqn_V2_InitNx2(1.f, 0));
|
||||
Dqn_f32 font_height = TELY_Render_FontHeight(renderer, &platform->assets);
|
||||
|
||||
next_pos.y += font_height;
|
||||
TELY_Render_TextF(renderer,
|
||||
next_pos,
|
||||
Dqn_V2_Zero,
|
||||
"%$$$d/%$$$d",
|
||||
player->terry_mobile_data_plan,
|
||||
player->terry_mobile_data_plan_cap);
|
||||
// TELY_Render_TextF(renderer, next_pos, Dqn_V2_Zero, "Terry");
|
||||
// next_pos.y += font_height;
|
||||
|
||||
// NOTE: Health bar ====================================================
|
||||
Dqn_f32 bar_height = font_height * .75f;
|
||||
Dqn_f32 bar_height = font_height * .75f;
|
||||
Dqn_Rect health_icon_rect = {};
|
||||
{
|
||||
next_pos.y += font_height;
|
||||
TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.icon_health);
|
||||
Dqn_Rect icon_tex_rect = game->atlas_sprite_sheet.rects.data[anim->index];
|
||||
{
|
||||
health_icon_rect.size = icon_tex_rect.size * .4f;
|
||||
health_icon_rect.pos = Dqn_V2_InitNx2(next_pos.x - health_icon_rect.size.x * .25f, next_pos.y - (health_icon_rect.size.y * .35f));
|
||||
}
|
||||
|
||||
Dqn_f32 bar_x = next_pos.x + (health_icon_rect.size.x * .25f);
|
||||
Dqn_f32 health_t = player->hp / DQN_CAST(Dqn_f32)player->hp_cap;
|
||||
Dqn_Rect health_rect = Dqn_Rect_InitNx4(next_pos.x, next_pos.y, DQN_CAST(Dqn_f32)player->hp_cap, bar_height);
|
||||
Dqn_Rect curr_health_rect = Dqn_Rect_InitNx4(next_pos.x, next_pos.y, DQN_CAST(Dqn_f32)player->hp_cap * health_t, bar_height);
|
||||
TELY_Render_RectColourV4(
|
||||
renderer,
|
||||
curr_health_rect,
|
||||
TELY_RenderShapeMode_Fill,
|
||||
TELY_COLOUR_RED_TOMATO_V4);
|
||||
Dqn_Rect health_rect = Dqn_Rect_InitNx4(bar_x, next_pos.y, DQN_CAST(Dqn_f32)player->hp_cap, bar_height);
|
||||
Dqn_Rect curr_health_rect = Dqn_Rect_InitNx4(bar_x, next_pos.y, DQN_CAST(Dqn_f32)player->hp_cap * health_t, bar_height);
|
||||
|
||||
TELY_Render_RectColourV4(renderer, curr_health_rect, TELY_RenderShapeMode_Fill, TELY_COLOUR_RED_TOMATO_V4);
|
||||
|
||||
TELY_RenderCommandRect *cmd = TELY_Render_RectColourV4(
|
||||
renderer,
|
||||
@@ -2561,14 +2561,41 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
|
||||
TELY_RenderShapeMode_Line,
|
||||
TELY_COLOUR_BLACK_V4);
|
||||
cmd->thickness = 4.f;
|
||||
|
||||
// NOTE: Draw the heart icon shadow
|
||||
TELY_Render_TextureColourV4(renderer,
|
||||
game->atlas_sprite_sheet.tex_handle,
|
||||
icon_tex_rect,
|
||||
Dqn_Rect_InitV2x2(health_icon_rect.pos - (cmd->thickness * 2.f), health_icon_rect.size + (cmd->thickness * 4.f)),
|
||||
Dqn_V2_Zero /*rotate origin*/,
|
||||
0.f /*rotation*/,
|
||||
TELY_COLOUR_BLACK_V4);
|
||||
|
||||
// NOTE: Draw the heart icon
|
||||
TELY_Render_TextureColourV4(renderer,
|
||||
game->atlas_sprite_sheet.tex_handle,
|
||||
icon_tex_rect,
|
||||
health_icon_rect,
|
||||
Dqn_V2_Zero /*rotate origin*/,
|
||||
0.f /*rotation*/,
|
||||
TELY_COLOUR_WHITE_V4);
|
||||
}
|
||||
|
||||
// NOTE: Stamina bar ===================================================
|
||||
next_pos.y += health_icon_rect.size.h * .8f;
|
||||
Dqn_Rect stamina_icon_rect = {};
|
||||
{
|
||||
next_pos.y += font_height;
|
||||
TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.icon_stamina);
|
||||
Dqn_Rect icon_tex_rect = game->atlas_sprite_sheet.rects.data[anim->index];
|
||||
{
|
||||
stamina_icon_rect.size = icon_tex_rect.size * .35f;
|
||||
stamina_icon_rect.pos = Dqn_V2_InitNx2(next_pos.x - stamina_icon_rect.size.x * .25f, next_pos.y - (stamina_icon_rect.size.y * .35f));
|
||||
}
|
||||
|
||||
Dqn_f32 bar_x = next_pos.x + (stamina_icon_rect.size.x * .25f);
|
||||
Dqn_f32 stamina_t = player->stamina / DQN_CAST(Dqn_f32)player->stamina_cap;
|
||||
Dqn_Rect stamina_rect = Dqn_Rect_InitNx4(next_pos.x, next_pos.y, DQN_CAST(Dqn_f32)player->stamina_cap, bar_height);
|
||||
Dqn_Rect curr_stamina_rect = Dqn_Rect_InitNx4(next_pos.x, next_pos.y, DQN_CAST(Dqn_f32)player->stamina_cap * stamina_t, bar_height);
|
||||
Dqn_Rect stamina_rect = Dqn_Rect_InitNx4(bar_x, next_pos.y, DQN_CAST(Dqn_f32)player->stamina_cap, bar_height);
|
||||
Dqn_Rect curr_stamina_rect = Dqn_Rect_InitNx4(bar_x, next_pos.y, DQN_CAST(Dqn_f32)player->stamina_cap * stamina_t, bar_height);
|
||||
TELY_Render_RectColourV4(
|
||||
renderer,
|
||||
curr_stamina_rect,
|
||||
@@ -2581,11 +2608,115 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
|
||||
TELY_RenderShapeMode_Line,
|
||||
TELY_COLOUR_BLACK_V4);
|
||||
cmd->thickness = 4.f;
|
||||
|
||||
// NOTE: Draw the icon shadow
|
||||
TELY_Render_TextureColourV4(renderer,
|
||||
game->atlas_sprite_sheet.tex_handle,
|
||||
icon_tex_rect,
|
||||
Dqn_Rect_InitV2x2(stamina_icon_rect.pos - (cmd->thickness * 2.f), stamina_icon_rect.size + (cmd->thickness * 4.f)),
|
||||
Dqn_V2_Zero /*rotate origin*/,
|
||||
0.f /*rotation*/,
|
||||
TELY_COLOUR_BLACK_V4);
|
||||
|
||||
// NOTE: Draw the icon
|
||||
TELY_Render_TextureColourV4(renderer,
|
||||
game->atlas_sprite_sheet.tex_handle,
|
||||
icon_tex_rect,
|
||||
stamina_icon_rect,
|
||||
Dqn_V2_Zero /*rotate origin*/,
|
||||
0.f /*rotation*/,
|
||||
TELY_COLOUR_WHITE_V4);
|
||||
}
|
||||
|
||||
next_pos.y += font_height;
|
||||
TELY_Render_TextF(renderer, next_pos, Dqn_V2_Zero, "$%I64u", player->coins);
|
||||
// NOTE: Mobile data bar ===================================================
|
||||
next_pos.y += stamina_icon_rect.size.h * .8f;
|
||||
Dqn_Rect phone_icon_rect = {};
|
||||
{
|
||||
TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.icon_phone);
|
||||
Dqn_Rect icon_tex_rect = game->atlas_sprite_sheet.rects.data[anim->index];
|
||||
{
|
||||
phone_icon_rect.size = icon_tex_rect.size * .35f;
|
||||
phone_icon_rect.pos = Dqn_V2_InitNx2(next_pos.x - phone_icon_rect.size.x * .25f, next_pos.y - (phone_icon_rect.size.y * .35f));
|
||||
}
|
||||
|
||||
Dqn_f32 pixels_per_kb = 15.5f;
|
||||
Dqn_f32 bar_width = DQN_CAST(Dqn_f32)player->terry_mobile_data_plan_cap / DQN_KILOBYTES(1) * pixels_per_kb;
|
||||
|
||||
Dqn_f32 bar_x = next_pos.x + (phone_icon_rect.size.x * .25f);
|
||||
Dqn_f32 data_plan_t = player->terry_mobile_data_plan / DQN_CAST(Dqn_f32)player->terry_mobile_data_plan_cap;
|
||||
Dqn_Rect data_plan_rect = Dqn_Rect_InitNx4(bar_x, next_pos.y, bar_width, bar_height);
|
||||
Dqn_Rect curr_data_plan_rect = Dqn_Rect_InitNx4(bar_x, next_pos.y, bar_width * data_plan_t, bar_height);
|
||||
TELY_Render_RectColourV4(
|
||||
renderer,
|
||||
curr_data_plan_rect,
|
||||
TELY_RenderShapeMode_Fill,
|
||||
TELY_COLOUR_BLUE_CADET_V4);
|
||||
|
||||
TELY_RenderCommandRect *cmd = TELY_Render_RectColourV4(
|
||||
renderer,
|
||||
data_plan_rect,
|
||||
TELY_RenderShapeMode_Line,
|
||||
TELY_COLOUR_BLACK_V4);
|
||||
cmd->thickness = 4.f;
|
||||
|
||||
// NOTE: Draw the icon shadow
|
||||
TELY_Render_TextureColourV4(renderer,
|
||||
game->atlas_sprite_sheet.tex_handle,
|
||||
icon_tex_rect,
|
||||
Dqn_Rect_InitV2x2(phone_icon_rect.pos - (cmd->thickness * 2.f), phone_icon_rect.size + (cmd->thickness * 4.f)),
|
||||
Dqn_V2_Zero /*rotate origin*/,
|
||||
0.f /*rotation*/,
|
||||
TELY_COLOUR_BLACK_V4);
|
||||
|
||||
// NOTE: Draw the icon
|
||||
TELY_Render_TextureColourV4(renderer,
|
||||
game->atlas_sprite_sheet.tex_handle,
|
||||
icon_tex_rect,
|
||||
phone_icon_rect,
|
||||
Dqn_V2_Zero /*rotate origin*/,
|
||||
0.f /*rotation*/,
|
||||
TELY_COLOUR_WHITE_V4);
|
||||
}
|
||||
|
||||
next_pos.y += phone_icon_rect.size.h * .8f;
|
||||
Dqn_Rect money_icon_rect = {};
|
||||
{
|
||||
TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.icon_money);
|
||||
Dqn_Rect icon_tex_rect = game->atlas_sprite_sheet.rects.data[anim->index];
|
||||
{
|
||||
money_icon_rect.size = icon_tex_rect.size * .35f;
|
||||
money_icon_rect.pos = Dqn_V2_InitNx2(next_pos.x - money_icon_rect.size.x * .25f, next_pos.y - (money_icon_rect.size.y * .15f));
|
||||
}
|
||||
|
||||
TELY_Render_TextF(renderer,
|
||||
Dqn_V2_InitNx2(next_pos.x + money_icon_rect.size.x * .75f, money_icon_rect.pos.y),
|
||||
Dqn_V2_InitNx2(0, -0.5),
|
||||
"$%I64u",
|
||||
player->coins);
|
||||
|
||||
// NOTE: Draw the icon shadow
|
||||
Dqn_f32 thickness = 4.f;
|
||||
TELY_Render_TextureColourV4(renderer,
|
||||
game->atlas_sprite_sheet.tex_handle,
|
||||
icon_tex_rect,
|
||||
Dqn_Rect_InitV2x2(money_icon_rect.pos - (thickness * 2.f), money_icon_rect.size + (thickness * 4.f)),
|
||||
Dqn_V2_Zero /*rotate origin*/,
|
||||
0.f /*rotation*/,
|
||||
TELY_COLOUR_BLACK_V4);
|
||||
|
||||
// NOTE: Draw the icon
|
||||
TELY_Render_TextureColourV4(renderer,
|
||||
game->atlas_sprite_sheet.tex_handle,
|
||||
icon_tex_rect,
|
||||
money_icon_rect,
|
||||
Dqn_V2_Zero /*rotate origin*/,
|
||||
0.f /*rotation*/,
|
||||
TELY_COLOUR_WHITE_V4);
|
||||
}
|
||||
|
||||
next_pos.y += money_icon_rect.size.h;
|
||||
|
||||
#if 0
|
||||
next_pos.y += font_height;
|
||||
TELY_Render_TextF(renderer, next_pos, Dqn_V2_Zero, "[H] Build Menu");
|
||||
|
||||
@@ -2597,6 +2728,7 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
|
||||
|
||||
next_pos.y += font_height;
|
||||
TELY_Render_TextF(renderer, next_pos, Dqn_V2_Zero, "[J|K] Melee/Range");
|
||||
#endif
|
||||
}
|
||||
|
||||
// NOTE: Render the wave ===================================================
|
||||
@@ -2661,7 +2793,7 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
|
||||
FP_GamePlaceableBuilding building = PLACEABLE_BUILDINGS[building_index];
|
||||
FP_EntityRenderData render_data = FP_Entity_GetRenderData(game, building.type, building.state, FP_GameDirection_Down);
|
||||
Dqn_Rect rect = Dqn_Rect_InitNx4(start_x + (building_index * building_ui_size) + (padding * building_index),
|
||||
Dqn_Rect_InterpolatedPoint(player_avatar_rect, Dqn_V2_InitNx2(0, 1.70)).y,
|
||||
next_pos.y,
|
||||
building_ui_size,
|
||||
building_ui_size);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user