fp: Draw health bars fro mobs, fix projectile origin
This commit is contained in:
parent
ecfe730744
commit
17947c7b69
@ -1322,8 +1322,7 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
|
|||||||
case FP_GameDirection_Count: break;
|
case FP_GameDirection_Count: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dqn_Rect entity_hit_box = FP_Game_CalcEntityWorldHitBox(game, entity->handle);
|
Dqn_V2 projectile_pos = FP_Game_CalcEntityWorldPos(game, entity->handle);
|
||||||
Dqn_V2 projectile_pos = entity_hit_box.pos + entity->attack_box_offset;
|
|
||||||
Dqn_V2 projectile_acceleration = FP_Game_MetersToPixelsV2(game->play, dir_vector * 0.25f);
|
Dqn_V2 projectile_acceleration = FP_Game_MetersToPixelsV2(game->play, dir_vector * 0.25f);
|
||||||
FP_Entity_CreatePhoneMessageProjectile(game,
|
FP_Entity_CreatePhoneMessageProjectile(game,
|
||||||
entity->handle,
|
entity->handle,
|
||||||
@ -1913,9 +1912,11 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
|||||||
// NOTE: Recover hp & stamina
|
// NOTE: Recover hp & stamina
|
||||||
entity->stamina = DQN_MIN(entity->stamina + 1, entity->stamina_cap);
|
entity->stamina = DQN_MIN(entity->stamina + 1, entity->stamina_cap);
|
||||||
|
|
||||||
|
if (entity->flags & FP_GameEntityFlag_RecoversHP) {
|
||||||
if (game->play.update_counter % 12 == 0) {
|
if (game->play.update_counter % 12 == 0) {
|
||||||
entity->hp = DQN_MIN(entity->hp + 1, entity->hp_cap);
|
entity->hp = DQN_MIN(entity->hp + 1, entity->hp_cap);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: Derive dynmamic bounding boxes ====================================================
|
// NOTE: Derive dynmamic bounding boxes ====================================================
|
||||||
if (entity->flags & FP_GameEntityFlag_DeriveHitBoxFromChildrenBoundingBox) {
|
if (entity->flags & FP_GameEntityFlag_DeriveHitBoxFromChildrenBoundingBox) {
|
||||||
@ -1969,7 +1970,7 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
|
|||||||
mob->flags |= FP_GameEntityFlag_Aggros;
|
mob->flags |= FP_GameEntityFlag_Aggros;
|
||||||
mob->flags |= FP_GameEntityFlag_RespondsToBuildings;
|
mob->flags |= FP_GameEntityFlag_RespondsToBuildings;
|
||||||
mob->hp_cap += hp_adjustment;
|
mob->hp_cap += hp_adjustment;
|
||||||
mob->hp = entity->hp_cap;
|
mob->hp = mob->hp_cap;
|
||||||
|
|
||||||
for (FP_GameEntity *waypoint_entity = entity->first_child; waypoint_entity; waypoint_entity = waypoint_entity->next) {
|
for (FP_GameEntity *waypoint_entity = entity->first_child; waypoint_entity; waypoint_entity = waypoint_entity->next) {
|
||||||
if ((waypoint_entity->flags & FP_GameEntityFlag_MobSpawnerWaypoint) == 0)
|
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);
|
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 ||
|
if (entity->type == FP_EntityType_ClubTerry ||
|
||||||
entity->type == FP_EntityType_AirportTerry ||
|
entity->type == FP_EntityType_AirportTerry ||
|
||||||
entity->type == FP_EntityType_ChurchTerry) {
|
entity->type == FP_EntityType_ChurchTerry) {
|
||||||
@ -2986,9 +3002,9 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: UI ====================================================================================
|
// NOTE: UI ====================================================================================
|
||||||
|
if (game->play.debug_ui) {
|
||||||
TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity());
|
TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity());
|
||||||
DQN_DEFER { TELY_Render_PopTransform(renderer); };
|
DQN_DEFER { TELY_Render_PopTransform(renderer); };
|
||||||
if (game->play.debug_ui) {
|
|
||||||
// NOTE: Info bar ==========================================================================
|
// NOTE: Info bar ==========================================================================
|
||||||
{
|
{
|
||||||
TELY_RFuiResult info_bar = TELY_RFui_Row(rfui, DQN_STRING8("Info Bar"));
|
TELY_RFuiResult info_bar = TELY_RFui_Row(rfui, DQN_STRING8("Info Bar"));
|
||||||
|
@ -464,6 +464,7 @@ static FP_GameEntityHandle FP_Entity_CreateTerry(FP_Game *game, Dqn_V2 pos, DQN_
|
|||||||
entity->flags |= FP_GameEntityFlag_NonTraversable;
|
entity->flags |= FP_GameEntityFlag_NonTraversable;
|
||||||
entity->flags |= FP_GameEntityFlag_Attackable;
|
entity->flags |= FP_GameEntityFlag_Attackable;
|
||||||
entity->flags |= FP_GameEntityFlag_CameraTracking;
|
entity->flags |= FP_GameEntityFlag_CameraTracking;
|
||||||
|
entity->flags |= FP_GameEntityFlag_RecoversHP;
|
||||||
entity->terry_mobile_data_plan_cap = DQN_KILOBYTES(6);
|
entity->terry_mobile_data_plan_cap = DQN_KILOBYTES(6);
|
||||||
entity->terry_mobile_data_plan = entity->terry_mobile_data_plan_cap;
|
entity->terry_mobile_data_plan = entity->terry_mobile_data_plan_cap;
|
||||||
entity->faction = FP_GameEntityFaction_Friendly;
|
entity->faction = FP_GameEntityFaction_Friendly;
|
||||||
|
@ -226,7 +226,7 @@ static FP_GameEntity *FP_Game_MakeEntityPointerFV(FP_Game *game, DQN_FMT_STRING_
|
|||||||
result->action.sprite_alpha = 1.f;
|
result->action.sprite_alpha = 1.f;
|
||||||
result->stamina_cap = 93;
|
result->stamina_cap = 93;
|
||||||
|
|
||||||
result->hp_cap = FP_DEFAULT_DAMAGE;
|
result->hp_cap = DQN_CAST(uint16_t)(FP_DEFAULT_DAMAGE * .8f);
|
||||||
result->hp = result->hp_cap;
|
result->hp = result->hp_cap;
|
||||||
|
|
||||||
result->inventory.airports_base_price = 100;
|
result->inventory.airports_base_price = 100;
|
||||||
|
@ -24,6 +24,7 @@ enum FP_GameEntityFlag
|
|||||||
FP_GameEntityFlag_Friendly = 1 << 16,
|
FP_GameEntityFlag_Friendly = 1 << 16,
|
||||||
FP_GameEntityFlag_Foe = 1 << 17,
|
FP_GameEntityFlag_Foe = 1 << 17,
|
||||||
FP_GameEntityFlag_NoClip = 1 << 18,
|
FP_GameEntityFlag_NoClip = 1 << 18,
|
||||||
|
FP_GameEntityFlag_RecoversHP = 1 << 19,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FP_GameShapeType
|
enum FP_GameShapeType
|
||||||
|
Loading…
Reference in New Issue
Block a user