fp: Render a $ amount on the merchant menu
This commit is contained in:
parent
fe4095b6bb
commit
09a83e3bfd
@ -486,6 +486,7 @@ void TELY_DLL_Init(void *user_data)
|
||||
game->inter_italic_font = platform->func_load_font(assets, DQN_STRING8("Inter (Italic)"), DQN_STRING8("Data/Inter-Italic.otf"), font_size);
|
||||
game->jetbrains_mono_font = platform->func_load_font(assets, DQN_STRING8("JetBrains Mono NL (Regular)"), DQN_STRING8("Data/JetBrainsMonoNL-Regular.ttf"), font_size);
|
||||
game->talkco_font = platform->func_load_font(assets, DQN_STRING8("Talkco"), DQN_STRING8("Data/Talkco.otf"), font_size);
|
||||
game->talkco_font_large = platform->func_load_font(assets, DQN_STRING8("Talkco"), DQN_STRING8("Data/Talkco.otf"), DQN_CAST(uint16_t)(font_size * 1.5f));
|
||||
game->audio[FP_GameAudio_TestAudio] = platform->func_load_audio(assets, DQN_STRING8("Test Audio"), DQN_STRING8("Data/Audio/Purrple Cat - Moonwinds.qoa"));
|
||||
game->audio[FP_GameAudio_TerryHit] = platform->func_load_audio(assets, DQN_STRING8("Terry Hit"), DQN_STRING8("Data/Audio/terry_hit.ogg"));
|
||||
game->audio[FP_GameAudio_Smooch] = platform->func_load_audio(assets, DQN_STRING8("Smooch"), DQN_STRING8("Data/Audio/smooch.mp3"));
|
||||
@ -2212,6 +2213,9 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
|
||||
continue;
|
||||
activated_merchant = true;
|
||||
|
||||
// NOTE: Render animated merchant menu
|
||||
Dqn_Rect merchant_menu_rect = {};
|
||||
{
|
||||
FP_GameRenderSprite *sprite = &game->player_merchant_menu;
|
||||
if (!sprite->asset.anim || sprite->asset.anim->label != mapping.menu_anim) {
|
||||
sprite->asset = TELY_Asset_MakeAnimatedSprite(&game->atlas_sprite_sheet, mapping.menu_anim, TELY_AssetFlip_No);
|
||||
@ -2225,20 +2229,39 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
|
||||
Dqn_usize sprite_index = sprite->asset.anim->index + anim_frame;
|
||||
Dqn_Rect src_rect = sprite->asset.sheet->rects.data[sprite_index];
|
||||
|
||||
Dqn_Rect dest_rect = {};
|
||||
dest_rect.size = src_rect.size;
|
||||
dest_rect.pos = world_pos - (dest_rect.size * .5f) - Dqn_V2_InitNx2(0.f, src_rect.size.y);
|
||||
|
||||
merchant_menu_rect.size = src_rect.size;
|
||||
merchant_menu_rect.pos = world_pos - (merchant_menu_rect.size * .5f) - Dqn_V2_InitNx2(0.f, src_rect.size.y);
|
||||
Dqn_f32 sin_t = DQN_SINF(DQN_CAST(Dqn_f32)input->timer_s * 3.f);
|
||||
dest_rect.pos.y += sin_t * 4.f;
|
||||
merchant_menu_rect.pos.y += sin_t * 4.f;
|
||||
|
||||
TELY_Render_TextureColourV4(renderer,
|
||||
sprite->asset.sheet->tex_handle,
|
||||
src_rect,
|
||||
merchant_menu_rect,
|
||||
Dqn_V2_Zero /*rotate origin*/,
|
||||
0.f /*rotation*/,
|
||||
TELY_COLOUR_WHITE_V4);
|
||||
}
|
||||
|
||||
// NOTE: Render the merchant button
|
||||
TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.merchant_button_a);
|
||||
Dqn_Rect button_rect = game->atlas_sprite_sheet.rects.data[anim->index];
|
||||
Dqn_Rect dest_rect = {};
|
||||
dest_rect.size = button_rect.size * 1.5f;
|
||||
dest_rect.pos = Dqn_Rect_InterpolatedPoint(merchant_menu_rect, Dqn_V2_InitNx2(0.75f, 0.5f));
|
||||
TELY_Render_TextureColourV4(renderer,
|
||||
game->atlas_sprite_sheet.tex_handle,
|
||||
button_rect,
|
||||
dest_rect,
|
||||
Dqn_V2_Zero /*rotate origin*/,
|
||||
0.f /*rotation*/,
|
||||
TELY_COLOUR_WHITE_V4);
|
||||
|
||||
TELY_Render_PushColourV4(renderer, TELY_COLOUR_WHITE_V4);
|
||||
TELY_Render_PushFont(renderer, game->talkco_font_large);
|
||||
TELY_Render_TextF(renderer, Dqn_Rect_InterpolatedPoint(dest_rect, Dqn_V2_InitNx2(0.5f, -1)), Dqn_V2_InitNx2(0.5, 0.f), "$2");
|
||||
TELY_Render_PopFont(renderer);
|
||||
TELY_Render_PopColourV4(renderer);
|
||||
}
|
||||
|
||||
if (activated_merchant) {
|
||||
|
@ -244,6 +244,7 @@ struct FP_Game
|
||||
TELY_AssetFontHandle inter_italic_font;
|
||||
TELY_AssetFontHandle jetbrains_mono_font;
|
||||
TELY_AssetFontHandle talkco_font;
|
||||
TELY_AssetFontHandle talkco_font_large;
|
||||
TELY_AssetAudioHandle audio[FP_GameAudio_Count];
|
||||
|
||||
Dqn_Slice<TELY_AssetSpriteAnimation> hero_sprite_anims;
|
||||
|
Loading…
Reference in New Issue
Block a user