fp: Integrate the icons

This commit is contained in:
doyle 2023-10-07 23:05:46 +11:00
parent b758a05809
commit 7e1bcee5df
29 changed files with 245 additions and 31 deletions

BIN
Data/Textures/atlas.png (Stored with Git LFS)

Binary file not shown.

BIN
Data/Textures/atlas.txt (Stored with Git LFS)

Binary file not shown.

BIN
Data/Textures/atlas/icon_health.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/icon_money.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/icon_phone.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/icon_stamina.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/particle_drunk_1.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/particle_drunk_2.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/particle_drunk_3.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/particle_heart_1.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/particle_heart_2.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/particle_purchase_1.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/particle_purchase_2.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/portal_1.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/portal_2.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/portal_3.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/portal_monk_1.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/portal_monk_2.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/terry_death_1.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/terry_death_2.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/terry_death_3.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/terry_death_4.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/terry_death_5.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/terry_pat_dog_1.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/atlas/terry_pat_dog_2.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Data/Textures/sprite_spec.txt (Stored with Git LFS)

Binary file not shown.

View File

@ -2512,6 +2512,7 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
// NOTE: Render player avatar HUD ========================================== // NOTE: Render player avatar HUD ==========================================
Dqn_Rect player_avatar_rect = {}; Dqn_Rect player_avatar_rect = {};
player_avatar_rect.pos = Dqn_V2_InitNx1(32.f); player_avatar_rect.pos = Dqn_V2_InitNx1(32.f);
Dqn_V2 next_pos = {};
{ {
TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity()); TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity());
DQN_DEFER { TELY_Render_PopTransform(renderer); }; 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); TELY_Render_PushFont(renderer, game->talkco_font);
DQN_DEFER { TELY_Render_PopFont(renderer); }; 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); Dqn_f32 font_height = TELY_Render_FontHeight(renderer, &platform->assets);
next_pos.y += font_height; // TELY_Render_TextF(renderer, next_pos, Dqn_V2_Zero, "Terry");
TELY_Render_TextF(renderer, // next_pos.y += font_height;
next_pos,
Dqn_V2_Zero,
"%$$$d/%$$$d",
player->terry_mobile_data_plan,
player->terry_mobile_data_plan_cap);
// NOTE: Health bar ==================================================== // 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_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 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(next_pos.x, next_pos.y, DQN_CAST(Dqn_f32)player->hp_cap * health_t, 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, TELY_Render_RectColourV4(renderer, curr_health_rect, TELY_RenderShapeMode_Fill, TELY_COLOUR_RED_TOMATO_V4);
curr_health_rect,
TELY_RenderShapeMode_Fill,
TELY_COLOUR_RED_TOMATO_V4);
TELY_RenderCommandRect *cmd = TELY_Render_RectColourV4( TELY_RenderCommandRect *cmd = TELY_Render_RectColourV4(
renderer, renderer,
@ -2561,14 +2561,41 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
TELY_RenderShapeMode_Line, TELY_RenderShapeMode_Line,
TELY_COLOUR_BLACK_V4); TELY_COLOUR_BLACK_V4);
cmd->thickness = 4.f; 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 =================================================== // 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_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 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(next_pos.x, next_pos.y, DQN_CAST(Dqn_f32)player->stamina_cap * stamina_t, 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( TELY_Render_RectColourV4(
renderer, renderer,
curr_stamina_rect, curr_stamina_rect,
@ -2581,11 +2608,115 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
TELY_RenderShapeMode_Line, TELY_RenderShapeMode_Line,
TELY_COLOUR_BLACK_V4); TELY_COLOUR_BLACK_V4);
cmd->thickness = 4.f; 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; // NOTE: Mobile data bar ===================================================
TELY_Render_TextF(renderer, next_pos, Dqn_V2_Zero, "$%I64u", player->coins); 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; next_pos.y += font_height;
TELY_Render_TextF(renderer, next_pos, Dqn_V2_Zero, "[H] Build Menu"); 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; next_pos.y += font_height;
TELY_Render_TextF(renderer, next_pos, Dqn_V2_Zero, "[J|K] Melee/Range"); TELY_Render_TextF(renderer, next_pos, Dqn_V2_Zero, "[J|K] Melee/Range");
#endif
} }
// NOTE: Render the wave =================================================== // 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_GamePlaceableBuilding building = PLACEABLE_BUILDINGS[building_index];
FP_EntityRenderData render_data = FP_Entity_GetRenderData(game, building.type, building.state, FP_GameDirection_Down); 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 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,
building_ui_size); building_ui_size);

View File

@ -50,6 +50,11 @@ struct FP_GlobalAnimations
Dqn_String8 heart = DQN_STRING8("heart"); Dqn_String8 heart = DQN_STRING8("heart");
Dqn_String8 heart_bleed = DQN_STRING8("heart_bleed"); Dqn_String8 heart_bleed = DQN_STRING8("heart_bleed");
Dqn_String8 icon_health = DQN_STRING8("icon_health");
Dqn_String8 icon_money = DQN_STRING8("icon_money");
Dqn_String8 icon_phone = DQN_STRING8("icon_phone");
Dqn_String8 icon_stamina = DQN_STRING8("icon_stamina");
Dqn_String8 kennel_terry = DQN_STRING8("kennel_terry"); Dqn_String8 kennel_terry = DQN_STRING8("kennel_terry");
Dqn_String8 map = DQN_STRING8("map"); Dqn_String8 map = DQN_STRING8("map");
@ -68,6 +73,12 @@ struct FP_GlobalAnimations
Dqn_String8 merchant_terry = DQN_STRING8("merchant_terry"); Dqn_String8 merchant_terry = DQN_STRING8("merchant_terry");
Dqn_String8 merchant_terry_menu = DQN_STRING8("merchant_terry_menu"); Dqn_String8 merchant_terry_menu = DQN_STRING8("merchant_terry_menu");
Dqn_String8 particle_drunk = DQN_STRING8("particle_drunk");
Dqn_String8 particle_heart = DQN_STRING8("particle_heart");
Dqn_String8 particle_purchase = DQN_STRING8("particle_purchase");
Dqn_String8 portal = DQN_STRING8("portal");
Dqn_String8 portal_monk = DQN_STRING8("portal_monk");
Dqn_String8 shadow_long_circle = DQN_STRING8("shadow_long_circle"); Dqn_String8 shadow_long_circle = DQN_STRING8("shadow_long_circle");
Dqn_String8 shadow_tight_circle = DQN_STRING8("shadow_tight_circle"); Dqn_String8 shadow_tight_circle = DQN_STRING8("shadow_tight_circle");
@ -93,6 +104,8 @@ struct FP_GlobalAnimations
Dqn_String8 terry_attack_phone_side = DQN_STRING8("terry_attack_phone_side"); Dqn_String8 terry_attack_phone_side = DQN_STRING8("terry_attack_phone_side");
Dqn_String8 terry_attack_phone_down = DQN_STRING8("terry_attack_phone_down"); Dqn_String8 terry_attack_phone_down = DQN_STRING8("terry_attack_phone_down");
Dqn_String8 terry_attack_phone_message = DQN_STRING8("terry_attack_phone_message"); Dqn_String8 terry_attack_phone_message = DQN_STRING8("terry_attack_phone_message");
Dqn_String8 terry_death = DQN_STRING8("terry_death");
Dqn_String8 terry_pat_dog = DQN_STRING8("terry_pat_dog");
Dqn_String8 terry_ghost = DQN_STRING8("terry_ghost"); Dqn_String8 terry_ghost = DQN_STRING8("terry_ghost");
Dqn_String8 terry_walk_idle = DQN_STRING8("terry_walk_idle"); Dqn_String8 terry_walk_idle = DQN_STRING8("terry_walk_idle");
Dqn_String8 terry_walk_up = DQN_STRING8("terry_walk_up"); Dqn_String8 terry_walk_up = DQN_STRING8("terry_walk_up");

View File

@ -224,7 +224,7 @@ static FP_GameEntity *FP_Game_MakeEntityPointerFV(FP_Game *game, DQN_FMT_STRING_
result->name = TELY_ChunkPool_AllocFmtFV(game->chunk_pool, fmt, args); result->name = TELY_ChunkPool_AllocFmtFV(game->chunk_pool, fmt, args);
result->buildings_visited = FP_SentinelList_Init<FP_GameEntityHandle>(game->chunk_pool); result->buildings_visited = FP_SentinelList_Init<FP_GameEntityHandle>(game->chunk_pool);
result->action.sprite_alpha = 1.f; result->action.sprite_alpha = 1.f;
result->stamina_cap = 100; result->stamina_cap = 93;
result->hp_cap = FP_DEFAULT_DAMAGE; result->hp_cap = FP_DEFAULT_DAMAGE;
result->hp = result->hp_cap; result->hp = result->hp_cap;