From 7a2b7618e86ea12f540e75f27c7f7090ad6834cc Mon Sep 17 00:00:00 2001 From: doyle Date: Sat, 21 Oct 2023 00:06:28 +1100 Subject: [PATCH] fp: Address warnings on GCC --- feely_pona.cpp | 19 ++++++++----------- feely_pona_game.cpp | 7 ++----- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/feely_pona.cpp b/feely_pona.cpp index 8367e19..ac8ae0d 100644 --- a/feely_pona.cpp +++ b/feely_pona.cpp @@ -1927,17 +1927,14 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input if (entity->handle != player) continue; - Dqn_V2 new_entity_pos = entity_pos; - Dqn_Rect camera_view_rect = Dqn_Rect_InitV2x2((camera->size * -.5f) + (camera->world_pos / camera->scale), camera->size); - - Dqn_Rect entity_hit_box = FP_Game_CalcEntityWorldHitBox(game, entity_handle); - Dqn_Rect playable_bounds = Dqn_Rect_ExpandV2(camera_view_rect, -entity_hit_box.size); - - Dqn_Rect hit_box = FP_Game_CalcEntityWorldHitBox(game, entity_handle); - new_entity_pos.x = DQN_MAX(new_entity_pos.x, playable_bounds.pos.x); - new_entity_pos.y = DQN_MAX(new_entity_pos.y, playable_bounds.pos.y); - new_entity_pos.x = DQN_MIN(new_entity_pos.x, playable_bounds.pos.x + playable_bounds.size.x); - new_entity_pos.y = DQN_MIN(new_entity_pos.y, playable_bounds.pos.y + playable_bounds.size.y); + Dqn_Rect const camera_view_rect = Dqn_Rect_InitV2x2((camera->size * -.5f) + (camera->world_pos / camera->scale), camera->size); + Dqn_Rect const entity_hit_box = FP_Game_CalcEntityWorldHitBox(game, entity_handle); + Dqn_Rect const playable_bounds = Dqn_Rect_ExpandV2(camera_view_rect, -entity_hit_box.size); + Dqn_V2 new_entity_pos = entity_pos; + new_entity_pos.x = DQN_MAX(new_entity_pos.x, playable_bounds.pos.x); + new_entity_pos.y = DQN_MAX(new_entity_pos.y, playable_bounds.pos.y); + new_entity_pos.x = DQN_MIN(new_entity_pos.x, playable_bounds.pos.x + playable_bounds.size.x); + new_entity_pos.y = DQN_MIN(new_entity_pos.y, playable_bounds.pos.y + playable_bounds.size.y); if (new_entity_pos != entity_pos) { entity_is_oob_with_camera = true; diff --git a/feely_pona_game.cpp b/feely_pona_game.cpp index cca389e..cb1ebca 100644 --- a/feely_pona_game.cpp +++ b/feely_pona_game.cpp @@ -1093,11 +1093,8 @@ static void FP_Game_MoveEntity(FP_Game *game, FP_GameEntityHandle entity_handle, if (DQN_ABS(entity->velocity.y) < 5.f) entity->velocity.y = 0.f; - Dqn_V2 const delta_pos = (acceleration * 0.5f * t_squared) + (entity->velocity * t); - Dqn_Rect const entity_world_hit_box = FP_Game_CalcEntityWorldHitBox(game, entity->handle); - Dqn_V2 const entity_pos = FP_Game_CalcEntityWorldPos(game, entity->handle); - Dqn_V2 const entity_new_pos = entity_pos + delta_pos; - + Dqn_V2 const delta_pos = (acceleration * 0.5f * t_squared) + (entity->velocity * t); + Dqn_V2 const entity_pos = FP_Game_CalcEntityWorldPos(game, entity->handle); FP_GameCanMoveToPositionResult move_to_result = FP_Game_CanEntityMoveToPosition(game, entity->handle, delta_pos); if (move_to_result.yes) { entity->local_pos += delta_pos;