fp: Mock up the buy trigger anim and logic
This commit is contained in:
parent
09a83e3bfd
commit
d5ceea9c94
@ -2222,6 +2222,17 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
|
|||||||
sprite->started_at_clock_ms = game->clock_ms;
|
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;
|
uint64_t elapsed_ms = game->clock_ms - sprite->started_at_clock_ms;
|
||||||
uint16_t raw_anim_frame = DQN_CAST(uint16_t)(elapsed_ms / sprite->asset.anim->ms_per_frame);
|
uint16_t raw_anim_frame = DQN_CAST(uint16_t)(elapsed_ms / sprite->asset.anim->ms_per_frame);
|
||||||
uint16_t anim_frame = raw_anim_frame % sprite->asset.anim->count;
|
uint16_t anim_frame = raw_anim_frame % sprite->asset.anim->count;
|
||||||
@ -2241,6 +2252,19 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
|
|||||||
Dqn_V2_Zero /*rotate origin*/,
|
Dqn_V2_Zero /*rotate origin*/,
|
||||||
0.f /*rotation*/,
|
0.f /*rotation*/,
|
||||||
TELY_COLOUR_WHITE_V4);
|
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
|
// NOTE: Render the merchant button
|
||||||
|
@ -260,6 +260,7 @@ struct FP_Game
|
|||||||
|
|
||||||
FP_GameEntityHandle player;
|
FP_GameEntityHandle player;
|
||||||
FP_GameRenderSprite player_merchant_menu;
|
FP_GameRenderSprite player_merchant_menu;
|
||||||
|
uint64_t player_trigger_purchase_timestamp;
|
||||||
|
|
||||||
FP_GameEntityHandle merchant_terry;
|
FP_GameEntityHandle merchant_terry;
|
||||||
FP_GameEntityHandle merchant_graveyard;
|
FP_GameEntityHandle merchant_graveyard;
|
||||||
|
Loading…
Reference in New Issue
Block a user