fp: Tweak hitbox of heart

This commit is contained in:
doyle 2023-10-01 16:20:05 +11:00
parent 0234d34673
commit dc657ae1c3
2 changed files with 8 additions and 7 deletions

View File

@ -1520,7 +1520,8 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
// NOTE: Render shapes in entity =========================================================== // NOTE: Render shapes in entity ===========================================================
Dqn_Rect world_hit_box = FP_Game_CalcEntityWorldHitBox(game, entity->handle); 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) { for (FP_GameShape const &shape_ : entity->shapes) {
FP_GameShape const *shape = &shape_; FP_GameShape const *shape = &shape_;
Dqn_V2 local_to_world_p1 = world_pos + shape->p1; Dqn_V2 local_to_world_p1 = world_pos + shape->p1;
@ -1698,11 +1699,10 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
if (game->hot_entity == entity->handle) { if (game->hot_entity == entity->handle) {
if (entity->name.size) { if (entity->name.size) {
Dqn_V2I player_tile = Dqn_V2I_InitNx2(world_pos.x / game->tile_size, world_pos.y / game->tile_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_f32 line_height = TELY_Render_FontHeight(renderer, &platform->assets);
Dqn_V2 draw_p = world_mouse_p; 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), "%.*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), "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; 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;
} }

View File

@ -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_f32 size_scale = FP_Entity_CalcSpriteScaleForDesiredHeight(game, entity->sprite_height, sprite_rect);
Dqn_V2 sprite_rect_scaled = sprite_rect.size * size_scale; 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); FP_Entity_AddDebugEditorFlags(game, result);
entity->flags |= FP_GameEntityFlag_NonTraversable; entity->flags |= FP_GameEntityFlag_NonTraversable;