fp: Park rotation work

This commit is contained in:
doyle 2023-09-30 17:49:49 +10:00
parent fbf94b12b9
commit 1c6037bbaa
2 changed files with 33 additions and 6 deletions

2
External/tely vendored

@ -1 +1 @@
Subproject commit 949f5e16338c7f981b38f03fc406dca3a499ab9a
Subproject commit f4390f0a385345efc07297317539d5eb6e8c9c09

View File

@ -339,7 +339,7 @@ void TELY_DLL_Init(void *user_data)
// NOTE: Mob spawner ===========================================================================
{
Dqn_V2 mob_spawner_pos = FP_Game_MetersToPixelsNx2(game, 2.f, 5.f);
FP_GameEntityHandle mob_spawner = FP_Entity_CreateMobSpawner(game, mob_spawner_pos, 1 /*spawn_cap*/, "Mob spawner");
FP_GameEntityHandle mob_spawner = FP_Entity_CreateMobSpawner(game, mob_spawner_pos, 128 /*spawn_cap*/, "Mob spawner");
FP_Game_PushParentEntity(game, mob_spawner);
FP_Entity_CreateWaypointF(game, FP_Game_MetersToPixelsNx2(game, 2.f, 4.f), "Waypoint A");
FP_Entity_CreateWaypointF(game, FP_Game_MetersToPixelsNx2(game, 14.f, 8.f), "Waypoint B");
@ -1355,7 +1355,8 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
continue;
// NOTE: Render shapes in entity ===========================================================
Dqn_V2 world_pos = FP_Game_CalcEntityWorldPos(game, entity->handle);
Dqn_Rect world_hit_box = FP_Game_CalcEntityWorldHitBox(game, entity->handle);
Dqn_V2 world_pos = Dqn_Rect_Center(world_hit_box);
for (FP_GameShape const &shape_ : entity->shapes) {
FP_GameShape const *shape = &shape_;
Dqn_V2 local_to_world_p1 = world_pos + shape->p1;
@ -1419,7 +1420,14 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
if (sprite.flip & TELY_AssetFlip_Y)
dest_rect.size.h *= -1.f; // NOTE: Flip the texture vertically
TELY_Render_TextureColourV4(renderer, sprite.sheet->tex_handle, src_rect, dest_rect, TELY_COLOUR_WHITE_V4);
Dqn_f32 rotate_radians = Dqn_PCG32_NextF32(&game->rng) * DQN_PI * 0.5f;
TELY_Render_TextureColourV4(renderer,
sprite.sheet->tex_handle,
src_rect,
dest_rect,
Dqn_V2_Zero /*rotate origin*/,
rotate_radians,
TELY_COLOUR_WHITE_V4);
}
DQN_FOR_UINDEX(anim_index, entity->extra_cosmetic_anims.size) {
@ -1463,7 +1471,27 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
if (sprite->asset.flip & TELY_AssetFlip_Y)
dest_rect.size.h *= -1.f; // NOTE: Flip the texture vertically
TELY_Render_TextureColourV4(renderer, sprite->asset.sheet->tex_handle, src_rect, dest_rect, TELY_COLOUR_WHITE_V4);
TELY_Render_TextureColourV4(renderer,
sprite->asset.sheet->tex_handle,
src_rect,
dest_rect,
Dqn_V2_Zero /*rotate origin*/,
0.f /*rotation*/,
TELY_COLOUR_WHITE_V4);
}
if (entity->type == FP_EntityType_ClubTerry) {
FP_EntityClubTerryState *state = DQN_CAST(FP_EntityClubTerryState *)&entity->action.state;
if (*state == FP_EntityClubTerryState_PartyTime) {
Dqn_f32 duration = entity->action.end_at_clock_ms - DQN_CAST(Dqn_f32)entity->action.started_at_clock_ms;
Dqn_f32 elapsed = DQN_CAST(Dqn_f32)(game->clock_ms - entity->action.started_at_clock_ms);
Dqn_f32 t01 = DQN_MIN(1.f, elapsed / duration);
Dqn_Rect rect = {};
rect.pos = Dqn_Rect_InterpolatedPoint(world_hit_box, Dqn_V2_InitNx2(0, -0.3f));
rect.size = Dqn_V2_InitNx2(world_hit_box.size.w * t01, 16.f);
TELY_Render_RectColourV4(renderer, rect, TELY_RenderShapeMode_Fill, TELY_Colour_V4Alpha(TELY_COLOUR_RED_TOMATO_V4, 1.0f));
}
}
// NOTE: Render waypoint entities ==========================================================
@ -1480,7 +1508,6 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
}
// NOTE: Render attack box =================================================================
Dqn_Rect world_hit_box = FP_Game_CalcEntityWorldHitBox(game, entity->handle);
{
Dqn_Rect attack_box = FP_Game_CalcEntityAttackWorldHitBox(game, entity->handle);
TELY_Render_RectColourV4(renderer, attack_box, TELY_RenderShapeMode_Line, TELY_COLOUR_RED_TOMATO_V4);