fp: Mock up the buy trigger anim and logic
This commit is contained in:
parent
09a83e3bfd
commit
d5ceea9c94
@ -2218,8 +2218,19 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
|
||||
{
|
||||
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);
|
||||
sprite->started_at_clock_ms = game->clock_ms;
|
||||
sprite->asset = TELY_Asset_MakeAnimatedSprite(&game->atlas_sprite_sheet, mapping.menu_anim, TELY_AssetFlip_No);
|
||||
sprite->started_at_clock_ms = game->clock_ms;
|
||||
}
|
||||
|
||||
bool trigger_buy_anim = false;
|
||||
uint64_t buy_duration_ms = 500;
|
||||
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_J)) {
|
||||
game->player_trigger_purchase_timestamp = game->clock_ms + buy_duration_ms;
|
||||
} else if (TELY_Platform_InputScanCodeIsDown(input, TELY_PlatformInputScanCode_J)) {
|
||||
trigger_buy_anim = true;
|
||||
if (game->clock_ms > game->player_trigger_purchase_timestamp) {
|
||||
// TODO(doyle): Do buy logic
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t elapsed_ms = game->clock_ms - sprite->started_at_clock_ms;
|
||||
@ -2241,6 +2252,19 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
|
||||
Dqn_V2_Zero /*rotate origin*/,
|
||||
0.f /*rotation*/,
|
||||
TELY_COLOUR_WHITE_V4);
|
||||
|
||||
if (trigger_buy_anim) {
|
||||
uint64_t start_buy_time = game->player_trigger_purchase_timestamp - buy_duration_ms;
|
||||
uint64_t elapsed_time = game->clock_ms - start_buy_time;
|
||||
|
||||
Dqn_f32 buy_t = DQN_MIN(elapsed_time / DQN_CAST(Dqn_f32)buy_duration_ms, 1.f);
|
||||
Dqn_Rect buy_lerp_rect = {};
|
||||
buy_lerp_rect.pos = Dqn_Rect_InterpolatedPoint(merchant_menu_rect, Dqn_V2_InitNx2(0.68f, 0.215f));
|
||||
buy_lerp_rect.size.w = (merchant_menu_rect.size.w * 0.211f) * buy_t;
|
||||
buy_lerp_rect.size.h = merchant_menu_rect.size.h * .611f;
|
||||
|
||||
TELY_Render_RectColourV4(renderer, buy_lerp_rect, TELY_RenderShapeMode_Fill, TELY_Colour_V4Alpha(TELY_COLOUR_RED_TOMATO_V4, 0.5f));
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Render the merchant button
|
||||
|
@ -260,6 +260,7 @@ struct FP_Game
|
||||
|
||||
FP_GameEntityHandle player;
|
||||
FP_GameRenderSprite player_merchant_menu;
|
||||
uint64_t player_trigger_purchase_timestamp;
|
||||
|
||||
FP_GameEntityHandle merchant_terry;
|
||||
FP_GameEntityHandle merchant_graveyard;
|
||||
|
Loading…
Reference in New Issue
Block a user