fp: Add terry ghosting

This commit is contained in:
2023-10-07 15:29:56 +11:00
parent fd0612ac1c
commit 19f8649870
13 changed files with 57 additions and 9 deletions
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+23 -2
View File
@@ -599,10 +599,31 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
uint64_t duration_ms = 250;
FP_Game_EntityActionReset(game, entity->handle, duration_ms, render_data.sprite);
*acceleration_meters_per_s *= 35.f;
#if 0
FP_GameRenderSprite *cosmetic_sprite = Dqn_FArray_Make(&entity->extra_cosmetic_anims, Dqn_ZeroMem_Yes);
if (cosmetic_sprite) {
cosmetic_sprite->asset = TELY_Asset_MakeAnimatedSprite(sheet, g_anim_names.terry_ghost, TELY_AssetFlip_No);
cosmetic_sprite->started_at_clock_ms = game->clock_ms;
cosmetic_sprite->height.meters = entity->sprite_height.meters;
uint32_t max_rng_dist_x = DQN_CAST(uint32_t)(FP_Game_MetersToPixelsNx1(game, entity->sprite_height.meters) * 1.f);
uint32_t rng_x = Dqn_PCG32_Range(&game->rng, DQN_CAST(uint32_t)0, max_rng_dist_x);
cosmetic_sprite->offset.x = rng_x - (max_rng_dist_x * .5f);
uint32_t max_rng_dist_y = DQN_CAST(uint32_t)(FP_Game_MetersToPixelsNx1(game, entity->sprite_height.meters) * .25f);
uint32_t rng_y = Dqn_PCG32_Range(&game->rng, DQN_CAST(uint32_t)0, max_rng_dist_y);
cosmetic_sprite->offset.y = -DQN_CAST(Dqn_f32)rng_y;
}
#endif
}
if (action_has_finished)
entity->action.sprite_alpha = Dqn_PCG32_NextF32(&game->rng);
if (action_has_finished) {
FP_Game_EntityTransitionState(game, entity, FP_EntityTerryState_Run);
entity->action.sprite_alpha = 1.f;
}
} break;
}
@@ -2062,7 +2083,7 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
dest_rect,
Dqn_V2_Zero /*rotate origin*/,
0.f /*rotate radians*/,
TELY_COLOUR_WHITE_V4);
TELY_Colour_V4Alpha(TELY_COLOUR_WHITE_V4, entity->action.sprite_alpha));
}
DQN_FOR_UINDEX(anim_index, entity->extra_cosmetic_anims.size) {
+1
View File
@@ -93,6 +93,7 @@ struct FP_GlobalAnimations
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_message = DQN_STRING8("terry_attack_phone_message");
Dqn_String8 terry_ghost = DQN_STRING8("terry_ghost");
Dqn_String8 terry_walk_idle = DQN_STRING8("terry_walk_idle");
Dqn_String8 terry_walk_up = DQN_STRING8("terry_walk_up");
Dqn_String8 terry_walk_down = DQN_STRING8("terry_walk_down");
+10 -1
View File
@@ -58,8 +58,17 @@ FP_EntityRenderData FP_Entity_GetRenderData(FP_Game *game, FP_EntityType type, u
}
} break;
case FP_EntityTerryState_Run: /*FALLTHRU*/
case FP_EntityTerryState_Dash: {
switch (direction) {
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_ghost; break;
case FP_GameDirection_Down: result.anim_name = g_anim_names.terry_ghost; break;
case FP_GameDirection_Left: result.anim_name = g_anim_names.terry_ghost; break;
case FP_GameDirection_Right: result.anim_name = g_anim_names.terry_ghost; result.flip = TELY_AssetFlip_X; break;
case FP_GameDirection_Count: DQN_INVALID_CODE_PATH; break;
}
} break;
case FP_EntityTerryState_Run: {
switch (direction) {
case FP_GameDirection_Up: result.anim_name = g_anim_names.terry_walk_up; break;
case FP_GameDirection_Down: result.anim_name = g_anim_names.terry_walk_down; break;
+1
View File
@@ -223,6 +223,7 @@ static FP_GameEntity *FP_Game_MakeEntityPointerFV(FP_Game *game, DQN_FMT_STRING_
result->parent = FP_Game_ActiveParentEntityPointer(game);
result->name = TELY_ChunkPool_AllocFmtFV(game->chunk_pool, fmt, args);
result->buildings_visited = FP_SentinelList_Init<FP_GameEntityHandle>(game->chunk_pool);
result->action.sprite_alpha = 1.f;
// NOTE: Attach entity as a child to the parent
FP_GameEntity *parent = result->parent;
+1
View File
@@ -120,6 +120,7 @@ struct FP_GameEntityAction
uint32_t state;
uint32_t next_state;
TELY_AssetAnimatedSprite sprite;
Dqn_f32 sprite_alpha;
uint64_t started_at_clock_ms;
uint64_t end_at_clock_ms;
};