fp: Smoochie teleport

This commit is contained in:
doyle 2023-10-08 20:51:54 +11:00
parent 0c266e4127
commit ef164fbbee
2 changed files with 54 additions and 6 deletions

View File

@ -1716,9 +1716,52 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
Dqn_V2 entity_to_waypoint_norm = Dqn_V2_Normalise(entity_to_waypoint);
acceleration_meters_per_s = entity_to_waypoint_norm * (entity->base_acceleration_per_s.meters * 0.25f);
if (entity->type == FP_EntityType_Clinger && game->play.clock_ms >= entity->clinger_next_dash_timestamp) {
entity->clinger_next_dash_timestamp = game->play.clock_ms + 2000;
acceleration_meters_per_s = entity_to_waypoint_norm * entity->base_acceleration_per_s.meters * 45.f;
if (entity->type == FP_EntityType_Smoochie) {
if (waypoint_entity->type == FP_EntityType_Terry) {
if (dist_to_waypoint_sq < DQN_SQUARED(FP_Game_MetersToPixelsNx1(game->play, 2.f)) &&
!entity->smoochie_has_teleported) {
if (entity->smoochie_teleport_timestamp == 0) {
entity->smoochie_teleport_timestamp = game->play.clock_ms + DQN_CAST(Dqn_usize)(Dqn_PCG32_NextF32(&game->play.rng) * 5000);
}
if (game->play.clock_ms < entity->smoochie_teleport_timestamp) {
Dqn_usize time_to_teleport_ms = entity->smoochie_teleport_timestamp - game->play.clock_ms;
if (time_to_teleport_ms < 2000)
entity->action.sprite_alpha = Dqn_PCG32_NextF32(&game->play.rng);
} else if (game->play.clock_ms >= entity->smoochie_teleport_timestamp) {
Dqn_Rect waypoint_rect = FP_Game_CalcEntityWorldHitBox(game, waypoint_entity->handle);
entity->smoochie_has_teleported = true;
entity->action.sprite_alpha = 1.f;
Dqn_FArray<Dqn_V2, FP_GameDirection_Count> teleport_pos = {};
if (waypoint_entity->direction != FP_GameDirection_Up) {
Dqn_FArray_Add(&teleport_pos, Dqn_Rect_InterpolatedPoint(waypoint_rect, Dqn_V2_InitNx2(0.5f, -1.2f)));
}
if (waypoint_entity->direction != FP_GameDirection_Down) {
Dqn_FArray_Add(&teleport_pos, Dqn_Rect_InterpolatedPoint(waypoint_rect, Dqn_V2_InitNx2(0.5f, +1.2f)));
}
if (waypoint_entity->direction != FP_GameDirection_Left) {
Dqn_FArray_Add(&teleport_pos, Dqn_Rect_InterpolatedPoint(waypoint_rect, Dqn_V2_InitNx2(-1.2f, +0.5f)));
}
if (waypoint_entity->direction != FP_GameDirection_Right) {
Dqn_FArray_Add(&teleport_pos, Dqn_Rect_InterpolatedPoint(waypoint_rect, Dqn_V2_InitNx2(+1.2f, +0.5f)));
}
uint32_t teleport_index = Dqn_PCG32_Range(&game->play.rng, 0, DQN_CAST(uint32_t)teleport_pos.size);
entity->local_pos = teleport_pos.data[teleport_index];
}
}
}
} else if (entity->type == FP_EntityType_Clinger) {
if (game->play.clock_ms >= entity->clinger_next_dash_timestamp) {
entity->clinger_next_dash_timestamp = game->play.clock_ms + 2000;
acceleration_meters_per_s = entity_to_waypoint_norm * entity->base_acceleration_per_s.meters * 45.f;
}
}
break;
}
@ -1998,9 +2041,12 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
Dqn_V2 entity_world_pos = FP_Game_CalcEntityWorldPos(game, entity->handle);
Dqn_Rect entity_hit_box = FP_Game_CalcEntityWorldHitBox(game, entity->handle);
Dqn_f32 step_y = (entity_hit_box.size.h / spawn_count) * 1.5f;
Dqn_V2 mob_world_pos = Dqn_V2_InitNx2(entity_world_pos.x,
entity_hit_box.pos.y + (Dqn_PCG32_NextF32(&game->play.rng) * step_y) + (step_y * spawn_index));
Dqn_f32 step_y = (entity_hit_box.size.h / spawn_count) * 1.5f;
Dqn_f32 mob_y_offset = (Dqn_PCG32_NextF32(&game->play.rng) * step_y) + (step_y * spawn_index);
if (Dqn_PCG32_NextF32(&game->play.rng) >= .5f)
mob_y_offset *= -1;
Dqn_V2 mob_world_pos = Dqn_V2_InitNx2(entity_world_pos.x, entity_world_pos.y + mob_y_offset);
Dqn_f32 mob_choice = Dqn_PCG32_NextF32(&game->play.rng);
if (mob_choice <= 0.33f)
link->data = FP_Entity_CreateClinger(game, mob_world_pos, "Clinger");

View File

@ -221,6 +221,8 @@ struct FP_GameEntity
Dqn_usize terry_mobile_data_plan;
Dqn_usize terry_mobile_data_plan_cap;
Dqn_usize clinger_next_dash_timestamp;
bool smoochie_has_teleported;
Dqn_usize smoochie_teleport_timestamp;
Dqn_usize coins;
FP_GameInventory inventory;