fp: Use animated sprites, use ms for animation duration

This commit is contained in:
2023-09-24 23:08:30 +10:00
parent 858a66786a
commit 677486e094
4 changed files with 161 additions and 176 deletions
+6 -22
View File
@@ -425,32 +425,16 @@ static Dqn_Rect FP_Game_CalcEntityWorldBoundingBox(FP_Game *game, FP_GameEntityH
return result;
}
// Transition the action into the desire state and set the flag to indicate it
// has just transitioned
static void FP_Game_EntityActionSetState(FP_GameEntityAction *action, uint32_t state)
{
if (!action)
return;
action->state = state;
action->flags |= FP_GameEntityActionFlag_StateTransition;
}
// Reset the timers and animation for the current action and set the duration
// for the new action.
static void FP_Game_EntityActionReset(FP_GameEntityAction *action, Dqn_f32 new_action_duration, FP_GameEntityActionSprite sprite)
static void FP_Game_EntityActionReset(FP_Game *game, FP_GameEntityHandle entity_handle, uint64_t duration_ms, TELY_AssetAnimatedSprite sprite)
{
if (!action)
FP_GameEntity *entity = FP_Game_GetEntity(game, entity_handle);
if (!entity)
return;
action->sprite = sprite;
action->timer_s = 0.f;
action->end_at_s = new_action_duration;
action->flags = 0;
}
static bool FP_Game_EntityActionHasFailed(FP_GameEntityAction const *action)
{
bool result = action ? action->flags & FP_GameEntityActionFlag_Failed : true;
return result;
entity->action.sprite = sprite;
entity->action.started_at_clock_ms = game->clock_ms;
entity->action.end_at_clock_ms = DQN_MAX(duration_ms, game->clock_ms + duration_ms);
}
static Dqn_V2I FP_Game_WorldPosToTilePos(FP_Game *game, Dqn_V2 world_pos)