fp: Draw health bars fro mobs, fix projectile origin
This commit is contained in:
+24
-8
@@ -1322,8 +1322,7 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
||||
case FP_GameDirection_Count: break;
|
||||
}
|
||||
|
||||
Dqn_Rect entity_hit_box = FP_Game_CalcEntityWorldHitBox(game, entity->handle);
|
||||
Dqn_V2 projectile_pos = entity_hit_box.pos + entity->attack_box_offset;
|
||||
Dqn_V2 projectile_pos = FP_Game_CalcEntityWorldPos(game, entity->handle);
|
||||
Dqn_V2 projectile_acceleration = FP_Game_MetersToPixelsV2(game->play, dir_vector * 0.25f);
|
||||
FP_Entity_CreatePhoneMessageProjectile(game,
|
||||
entity->handle,
|
||||
@@ -1913,8 +1912,10 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
||||
// NOTE: Recover hp & stamina
|
||||
entity->stamina = DQN_MIN(entity->stamina + 1, entity->stamina_cap);
|
||||
|
||||
if (game->play.update_counter % 12 == 0) {
|
||||
entity->hp = DQN_MIN(entity->hp + 1, entity->hp_cap);
|
||||
if (entity->flags & FP_GameEntityFlag_RecoversHP) {
|
||||
if (game->play.update_counter % 12 == 0) {
|
||||
entity->hp = DQN_MIN(entity->hp + 1, entity->hp_cap);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Derive dynmamic bounding boxes ====================================================
|
||||
@@ -1968,8 +1969,8 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
||||
mob->waypoints = FP_SentinelList_Init<FP_GameWaypoint>(game->play.chunk_pool);
|
||||
mob->flags |= FP_GameEntityFlag_Aggros;
|
||||
mob->flags |= FP_GameEntityFlag_RespondsToBuildings;
|
||||
mob->hp_cap += hp_adjustment;
|
||||
mob->hp = entity->hp_cap;
|
||||
mob->hp_cap += hp_adjustment;
|
||||
mob->hp = mob->hp_cap;
|
||||
|
||||
for (FP_GameEntity *waypoint_entity = entity->first_child; waypoint_entity; waypoint_entity = waypoint_entity->next) {
|
||||
if ((waypoint_entity->flags & FP_GameEntityFlag_MobSpawnerWaypoint) == 0)
|
||||
@@ -2268,6 +2269,21 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
||||
TELY_COLOUR_WHITE_V4);
|
||||
}
|
||||
|
||||
if (entity->handle != game->play.player && entity->hp != entity->hp_cap && entity->hp) {
|
||||
Dqn_f32 bar_height = 12.f;
|
||||
TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.icon_health);
|
||||
Dqn_Rect icon_tex_rect = game->atlas_sprite_sheet.rects.data[anim->index];
|
||||
|
||||
Dqn_V2 draw_p = Dqn_Rect_InterpolatedPoint(world_hit_box, Dqn_V2_InitNx2(0.f, -0.2f));
|
||||
Dqn_f32 health_t = entity->hp / DQN_CAST(Dqn_f32)entity->hp_cap;
|
||||
Dqn_Rect health_rect = Dqn_Rect_InitNx4(draw_p.x, draw_p.y, DQN_CAST(Dqn_f32)entity->hp_cap, bar_height);
|
||||
Dqn_Rect curr_health_rect = Dqn_Rect_InitNx4(draw_p.x, draw_p.y, DQN_CAST(Dqn_f32)entity->hp_cap * health_t, bar_height);
|
||||
|
||||
TELY_Render_RectColourV4(renderer, curr_health_rect, TELY_RenderShapeMode_Fill, TELY_COLOUR_RED_TOMATO_V4);
|
||||
TELY_RenderCommandRect *cmd = TELY_Render_RectColourV4(renderer, health_rect, TELY_RenderShapeMode_Line, TELY_COLOUR_BLACK_V4);
|
||||
cmd->thickness = 1.f;
|
||||
}
|
||||
|
||||
if (entity->type == FP_EntityType_ClubTerry ||
|
||||
entity->type == FP_EntityType_AirportTerry ||
|
||||
entity->type == FP_EntityType_ChurchTerry) {
|
||||
@@ -2986,9 +3002,9 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
||||
}
|
||||
|
||||
// NOTE: UI ====================================================================================
|
||||
TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity());
|
||||
DQN_DEFER { TELY_Render_PopTransform(renderer); };
|
||||
if (game->play.debug_ui) {
|
||||
TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity());
|
||||
DQN_DEFER { TELY_Render_PopTransform(renderer); };
|
||||
// NOTE: Info bar ==========================================================================
|
||||
{
|
||||
TELY_RFuiResult info_bar = TELY_RFui_Row(rfui, DQN_STRING8("Info Bar"));
|
||||
|
||||
Reference in New Issue
Block a user