From dc657ae1c35f0900c8d6ea25788b7424466699e6 Mon Sep 17 00:00:00 2001 From: doyle Date: Sun, 1 Oct 2023 16:20:05 +1100 Subject: [PATCH] fp: Tweak hitbox of heart --- feely_pona.cpp | 12 ++++++------ feely_pona_entity_create.cpp | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/feely_pona.cpp b/feely_pona.cpp index ef6baa6..016af2c 100644 --- a/feely_pona.cpp +++ b/feely_pona.cpp @@ -1520,7 +1520,8 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer) // NOTE: Render shapes in entity =========================================================== Dqn_Rect world_hit_box = FP_Game_CalcEntityWorldHitBox(game, entity->handle); - Dqn_V2 world_pos = Dqn_Rect_Center(world_hit_box); + Dqn_V2 world_pos = FP_Game_CalcEntityWorldPos(game, entity->handle); + for (FP_GameShape const &shape_ : entity->shapes) { FP_GameShape const *shape = &shape_; Dqn_V2 local_to_world_p1 = world_pos + shape->p1; @@ -1697,12 +1698,11 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer) if (game->hot_entity == entity->handle) { if (entity->name.size) { - Dqn_V2I player_tile = Dqn_V2I_InitNx2(world_pos.x / game->tile_size, world_pos.y / game->tile_size); - Dqn_V2 entity_world_pos = Dqn_Rect_Center(world_hit_box); - Dqn_f32 line_height = TELY_Render_FontHeight(renderer, &platform->assets); - Dqn_V2 draw_p = world_mouse_p; + Dqn_V2I player_tile = Dqn_V2I_InitNx2(world_pos.x / game->tile_size, world_pos.y / game->tile_size); + Dqn_f32 line_height = TELY_Render_FontHeight(renderer, &platform->assets); + Dqn_V2 draw_p = world_mouse_p; TELY_Render_TextF(renderer, draw_p, Dqn_V2_InitNx2(0.f, 1), "%.*s", DQN_STRING_FMT(entity->name)); draw_p.y += line_height; - TELY_Render_TextF(renderer, draw_p, Dqn_V2_InitNx2(0.f, 1), "World Pos: (%.1f, %.1f)", entity_world_pos.x, entity_world_pos.y); draw_p.y += line_height; + TELY_Render_TextF(renderer, draw_p, Dqn_V2_InitNx2(0.f, 1), "World Pos: (%.1f, %.1f)", world_pos.x, world_pos.y); draw_p.y += line_height; TELY_Render_TextF(renderer, draw_p, Dqn_V2_InitNx2(0.f, 1), "Hit Box Size: %.1fx%.1f", world_hit_box.size.x, world_hit_box.size.y); draw_p.y += line_height; TELY_Render_TextF(renderer, draw_p, Dqn_V2_InitNx2(0.f, 1), "Tile: %I32dx%I32d", player_tile.x, player_tile.y); draw_p.y += line_height; } diff --git a/feely_pona_entity_create.cpp b/feely_pona_entity_create.cpp index 0d6d74d..57128e5 100644 --- a/feely_pona_entity_create.cpp +++ b/feely_pona_entity_create.cpp @@ -209,7 +209,8 @@ static FP_GameEntityHandle FP_Entity_CreateHeart(FP_Game *game, Dqn_V2 pos, DQN_ Dqn_f32 size_scale = FP_Entity_CalcSpriteScaleForDesiredHeight(game, entity->sprite_height, sprite_rect); Dqn_V2 sprite_rect_scaled = sprite_rect.size * size_scale; - entity->local_hit_box_size = Dqn_V2_InitNx2(sprite_rect_scaled.w - (sprite_rect_scaled.w * .1f), sprite_rect_scaled.h); + entity->local_hit_box_offset = Dqn_V2_InitNx2(0, sprite_rect_scaled.h * .15f); + entity->local_hit_box_size = Dqn_V2_InitNx2(sprite_rect_scaled.w - (sprite_rect_scaled.w * .3f), sprite_rect_scaled.h - (sprite_rect_scaled.h * .4f)); FP_Entity_AddDebugEditorFlags(game, result); entity->flags |= FP_GameEntityFlag_NonTraversable;