fp: Get closer to supporting web deployment

This commit is contained in:
doyle 2023-10-15 01:31:33 +11:00
parent 418599451d
commit ac898aec6a
7 changed files with 122 additions and 66 deletions

2
.clangd Normal file
View File

@ -0,0 +1,2 @@
CompileFlags:
Add: [-D_CLANGD=1]

2
External/tely vendored

@ -1 +1 @@
Subproject commit 145a0e83ad0300a95a527922d4a0446bb9742b57 Subproject commit 7e37d8655eb5e8c4a61501f054e87ef4b405306c

View File

@ -217,6 +217,9 @@ static void FP_Game_MoveEntity(FP_Game *game, FP_GameEntityHandle entity_handle,
case FP_EntityType_ChurchTerry: break; case FP_EntityType_ChurchTerry: break;
case FP_EntityType_KennelTerry: break; case FP_EntityType_KennelTerry: break;
case FP_EntityType_PhoneMessageProjectile: break; case FP_EntityType_PhoneMessageProjectile: break;
case FP_EntityType_AirportTerryPlane:
case FP_EntityType_MobSpawner:
case FP_EntityType_PortalMonkey: break;
} }
if (!entity_collides_with_collider) if (!entity_collides_with_collider)
@ -465,12 +468,10 @@ static void FP_PlayReset(FP_Game *game, TELY_Platform *platform)
FP_Entity_CreateAirportTerry(game, Dqn_V2_InitNx2(-1200, -191), "Airport Terry"); FP_Entity_CreateAirportTerry(game, Dqn_V2_InitNx2(-1200, -191), "Airport Terry");
#endif #endif
play->tile_size = 37;
Dqn_V2I max_tile = platform->core.window_size / play->tile_size;
// NOTE: Heart // NOTE: Heart
game->play.heart = FP_Entity_CreateHeart(game, base_mid_p, "Heart"); game->play.heart = FP_Entity_CreateHeart(game, base_mid_p, "Heart");
play->camera.world_pos = base_mid_p - Dqn_V2_InitV2I(platform->core.window_size * .5f); play->camera.world_pos = base_mid_p - Dqn_V2_InitV2I(platform->core.window_size * .5f);
play->tile_size = 37;
play->camera.scale = Dqn_V2_InitNx1(1); play->camera.scale = Dqn_V2_InitNx1(1);
} }
@ -577,7 +578,6 @@ FP_GetClosestPortalMonkeyResult FP_GetClosestPortalMonkey(FP_Game *game, FP_Game
// NOTE: Check if we are nearby a monkey and picking it up // NOTE: Check if we are nearby a monkey and picking it up
FP_GetClosestPortalMonkeyResult result = {}; FP_GetClosestPortalMonkeyResult result = {};
result.dist = DQN_F32_MAX; result.dist = DQN_F32_MAX;
FP_GameEntityHandle best_portal_monkey = {};
for (FP_GameEntityHandle portal_monkey_handle : game->play.portal_monkeys) { for (FP_GameEntityHandle portal_monkey_handle : game->play.portal_monkeys) {
FP_GameEntity *portal_monkey = FP_Game_GetEntity(game, portal_monkey_handle); FP_GameEntity *portal_monkey = FP_Game_GetEntity(game, portal_monkey_handle);
if (FP_Game_IsNilEntity(portal_monkey)) if (FP_Game_IsNilEntity(portal_monkey))
@ -1349,6 +1349,7 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
} break; } break;
} }
} break; } break;
case FP_EntityType_PortalMonkey: break;
} }
switch (entity->type) { switch (entity->type) {
@ -1432,6 +1433,8 @@ void FP_EntityActionStateMachine(FP_Game *game, TELY_Audio *audio, TELY_Platform
} break; } break;
case FP_EntityType_AirportTerryPlane: break; case FP_EntityType_AirportTerryPlane: break;
case FP_EntityType_MobSpawner:
case FP_EntityType_PortalMonkey: break;
} }
} }
@ -1556,6 +1559,8 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
case FP_EntityType_KennelTerry: break; case FP_EntityType_KennelTerry: break;
case FP_EntityType_PhoneMessageProjectile: break; case FP_EntityType_PhoneMessageProjectile: break;
case FP_EntityType_AirportTerryPlane: break; case FP_EntityType_AirportTerryPlane: break;
case FP_EntityType_MobSpawner:
case FP_EntityType_PortalMonkey: break;
} }
if (move_entity) { if (move_entity) {
@ -1687,14 +1692,10 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
} }
if (!has_waypoint_to_building) { if (!has_waypoint_to_building) {
Dqn_Rect hit_box = FP_Game_CalcEntityWorldHitBox(game, closest_building.entity); FP_SentinelListLink<FP_GameWaypoint> *link = FP_SentinelList_MakeBefore(&entity->waypoints, FP_SentinelList_Front(&entity->waypoints), game->play.chunk_pool);
Dqn_V2 top_left = Dqn_Rect_TopLeft(hit_box); FP_GameWaypoint *waypoint = &link->data;
Dqn_V2 top_right = Dqn_Rect_TopRight(hit_box); waypoint->entity = closest_building.entity;
waypoint->type = FP_GameWaypointType_Queue;
FP_SentinelListLink<FP_GameWaypoint> *link = FP_SentinelList_MakeBefore(&entity->waypoints, FP_SentinelList_Front(&entity->waypoints), game->play.chunk_pool);
FP_GameWaypoint *waypoint = &link->data;
waypoint->entity = closest_building.entity;
waypoint->type = FP_GameWaypointType_Queue;
// NOTE: Add the entity to the building queue // NOTE: Add the entity to the building queue
FP_GameEntity *building = FP_Game_GetEntity(game, closest_building.entity); FP_GameEntity *building = FP_Game_GetEntity(game, closest_building.entity);
@ -1814,7 +1815,6 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
Dqn_f32 arrival_threshold = {}; Dqn_f32 arrival_threshold = {};
switch (waypoint->arrive) { switch (waypoint->arrive) {
case FP_GameWaypointArrive_Default: { case FP_GameWaypointArrive_Default: {
Dqn_Rect waypoint_hit_box = FP_Game_CalcEntityWorldHitBox(game, waypoint_entity->handle);
if (approach_dir == FP_GameDirection_Up || approach_dir == FP_GameDirection_Down) if (approach_dir == FP_GameDirection_Up || approach_dir == FP_GameDirection_Down)
arrival_threshold = 10.f; arrival_threshold = 10.f;
else else
@ -1888,10 +1888,9 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
aggro |= entity->faction == FP_GameEntityFaction_Foe && waypoint_entity->faction & FP_GameEntityFaction_Friendly; aggro |= entity->faction == FP_GameEntityFaction_Foe && waypoint_entity->faction & FP_GameEntityFaction_Friendly;
} }
bool building_response = (entity->flags & FP_GameEntityFlag_RespondsToBuildings) && bool building_response = ((entity->flags & FP_GameEntityFlag_RespondsToBuildings) && (waypoint_entity->type == FP_EntityType_ClubTerry)) ||
waypoint_entity->type == FP_EntityType_ClubTerry || (waypoint_entity->type == FP_EntityType_AirportTerry) ||
waypoint_entity->type == FP_EntityType_AirportTerry || (waypoint_entity->type == FP_EntityType_ChurchTerry);
waypoint_entity->type == FP_EntityType_ChurchTerry;
if (aggro || building_response) { if (aggro || building_response) {
bool can_attack = !entity->is_dying; // TODO(doyle): State transition needs to check if it's valid to move to making this not necessary bool can_attack = !entity->is_dying; // TODO(doyle): State transition needs to check if it's valid to move to making this not necessary
@ -1975,6 +1974,9 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
case FP_EntityType_KennelTerry: break; case FP_EntityType_KennelTerry: break;
case FP_EntityType_PhoneMessageProjectile: break; case FP_EntityType_PhoneMessageProjectile: break;
case FP_EntityType_Count: DQN_INVALID_CODE_PATH; break; case FP_EntityType_Count: DQN_INVALID_CODE_PATH; break;
case FP_EntityType_AirportTerryPlane:
case FP_EntityType_MobSpawner:
case FP_EntityType_PortalMonkey: break;
} }
} }
@ -2216,9 +2218,7 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
if (!Dqn_V2_Area(attacker->attack_box_size)) if (!Dqn_V2_Area(attacker->attack_box_size))
continue; continue;
Dqn_Rect attacker_box = FP_Game_CalcEntityAttackWorldHitBox(game, attacker->handle); Dqn_Rect attacker_box = FP_Game_CalcEntityAttackWorldHitBox(game, attacker->handle);
Dqn_V2 attacker_world_pos = FP_Game_CalcEntityWorldPos(game, attacker->handle);
FP_GameEntityFaction enemy_faction = FP_GameEntityFaction enemy_faction =
entity->faction == FP_GameEntityFaction_Friendly entity->faction == FP_GameEntityFaction_Friendly
? FP_GameEntityFaction_Foe ? FP_GameEntityFaction_Foe
@ -2296,12 +2296,8 @@ void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput *input
} }
if (!FP_Game_IsNilEntityHandle(game, game->play.clicked_entity)) { if (!FP_Game_IsNilEntityHandle(game, game->play.clicked_entity)) {
TELY_AssetSpriteAnimation *sprite_anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.map); Dqn_usize const target_width = 1800;
Dqn_Rect sprite_rect = game->atlas_sprite_sheet.rects.data[sprite_anim->index]; Dqn_usize const target_height = 1046;
const Dqn_usize target_width = 1800;
const Dqn_usize target_height = 1046;
game->play.camera.world_pos.x = DQN_MIN(game->play.camera.world_pos.x, game->play.map->local_hit_box_size.w * +0.5f - target_width); game->play.camera.world_pos.x = DQN_MIN(game->play.camera.world_pos.x, game->play.map->local_hit_box_size.w * +0.5f - target_width);
game->play.camera.world_pos.x = DQN_MAX(game->play.camera.world_pos.x, game->play.map->local_hit_box_size.w * -0.5f); game->play.camera.world_pos.x = DQN_MAX(game->play.camera.world_pos.x, game->play.map->local_hit_box_size.w * -0.5f);
game->play.camera.world_pos.y = DQN_MAX(game->play.camera.world_pos.y, game->play.map->local_hit_box_size.h * -0.5f); game->play.camera.world_pos.y = DQN_MAX(game->play.camera.world_pos.y, game->play.map->local_hit_box_size.h * -0.5f);
@ -2498,13 +2494,10 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
if (entity->handle != game->play.player && entity->handle != game->play.heart && entity->hp != entity->hp_cap && entity->hp) { if (entity->handle != game->play.player && entity->handle != game->play.heart && entity->hp != entity->hp_cap && entity->hp) {
Dqn_f32 bar_height = 12.f; Dqn_f32 bar_height = 12.f;
TELY_AssetSpriteAnimation *anim = TELY_Asset_GetSpriteAnimation(&game->atlas_sprite_sheet, g_anim_names.icon_health); Dqn_V2 draw_p = Dqn_Rect_InterpolatedPoint(world_hit_box, Dqn_V2_InitNx2(0.f, -0.2f));
Dqn_Rect icon_tex_rect = game->atlas_sprite_sheet.rects.data[anim->index]; 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_V2 draw_p = Dqn_Rect_InterpolatedPoint(world_hit_box, Dqn_V2_InitNx2(0.f, -0.2f)); 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);
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_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); TELY_RenderCommandRect *cmd = TELY_Render_RectColourV4(renderer, health_rect, TELY_RenderShapeMode_Line, TELY_COLOUR_BLACK_V4);
@ -2516,9 +2509,9 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
entity->type == FP_EntityType_ChurchTerry) { entity->type == FP_EntityType_ChurchTerry) {
FP_GameEntityAction const *action = &entity->action; FP_GameEntityAction const *action = &entity->action;
bool draw_timer = entity->type == FP_EntityType_ClubTerry && action->state == FP_EntityClubTerryState_PartyTime || bool draw_timer = (entity->type == FP_EntityType_ClubTerry && action->state == FP_EntityClubTerryState_PartyTime) ||
entity->type == FP_EntityType_AirportTerry && action->state == FP_EntityAirportTerryState_FlyPassenger || (entity->type == FP_EntityType_AirportTerry && action->state == FP_EntityAirportTerryState_FlyPassenger) ||
entity->type == FP_EntityType_ChurchTerry && action->state == FP_EntityChurchTerryState_ConvertPatron; (entity->type == FP_EntityType_ChurchTerry && action->state == FP_EntityChurchTerryState_ConvertPatron);
if (draw_timer) { if (draw_timer) {
Dqn_f32 duration = action->end_at_clock_ms - DQN_CAST(Dqn_f32)action->started_at_clock_ms; Dqn_f32 duration = action->end_at_clock_ms - DQN_CAST(Dqn_f32)action->started_at_clock_ms;
Dqn_f32 elapsed = DQN_CAST(Dqn_f32)(game->play.clock_ms - action->started_at_clock_ms); Dqn_f32 elapsed = DQN_CAST(Dqn_f32)(game->play.clock_ms - action->started_at_clock_ms);
@ -2617,7 +2610,7 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
} }
// NOTE: Render overlay UI ===================================================================== // NOTE: Render overlay UI =====================================================================
if (game->play.state == FP_GameState_Pause || game->play.state == FP_GameState_Play) { if (!game->play.debug_hide_hud && (game->play.state == FP_GameState_Pause || game->play.state == FP_GameState_Play)) {
// NOTE: Render the merchant menus ========================================================= // NOTE: Render the merchant menus =========================================================
FP_GameEntity *player = FP_Game_GetEntity(game, game->play.player); FP_GameEntity *player = FP_Game_GetEntity(game, game->play.player);
@ -2891,9 +2884,6 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
next_pos = Dqn_Rect_InterpolatedPoint(player_avatar_rect, Dqn_V2_InitNx2(1.f, 0)); next_pos = Dqn_Rect_InterpolatedPoint(player_avatar_rect, Dqn_V2_InitNx2(1.f, 0));
Dqn_f32 font_height = TELY_Render_FontHeight(renderer, &platform->assets); Dqn_f32 font_height = TELY_Render_FontHeight(renderer, &platform->assets);
// TELY_Render_TextF(renderer, next_pos, Dqn_V2_Zero, "Terry");
// next_pos.y += font_height;
// NOTE: Health bar ==================================================== // NOTE: Health bar ====================================================
Dqn_f32 bar_height = font_height * .75f; Dqn_f32 bar_height = font_height * .75f;
Dqn_Rect health_icon_rect = {}; Dqn_Rect health_icon_rect = {};
@ -3363,6 +3353,9 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
TELY_Render_PushFont(renderer, game->inter_regular_font); TELY_Render_PushFont(renderer, game->inter_regular_font);
Dqn_f32 t = (DQN_SINF(DQN_CAST(Dqn_f32)input->timer_s * 5.f) + 1.f) / 2.f; Dqn_f32 t = (DQN_SINF(DQN_CAST(Dqn_f32)input->timer_s * 5.f) + 1.f) / 2.f;
#if defined(DQN_PLATFORM_EMSCRIPTEN)
TraceLog(LOG_ERROR, "update_counter: %llu, sin_f: %.1f, timer_s: %.1f, t: %.1f", game->play.update_counter, DQN_SINF(DQN_CAST(Dqn_f32)input->timer_s * 5.f), input->timer_s, t);
#endif
TELY_Render_PushColourV4(renderer, TELY_Colour_V4Alpha(TELY_COLOUR_WHITE_V4, t)); TELY_Render_PushColourV4(renderer, TELY_Colour_V4Alpha(TELY_COLOUR_WHITE_V4, t));
TELY_Render_TextF(renderer, Dqn_Rect_InterpolatedPoint(window_rect, Dqn_V2_InitNx2(0.5f, 0.925f)), Dqn_V2_InitNx1(0.5f), "Press enter to %s", game->play.state == FP_GameState_Play ? "start" : "restart"); TELY_Render_TextF(renderer, Dqn_Rect_InterpolatedPoint(window_rect, Dqn_V2_InitNx2(0.5f, 0.925f)), Dqn_V2_InitNx1(0.5f), "Press enter to %s", game->play.state == FP_GameState_Play ? "start" : "restart");
TELY_Render_PopColourV4(renderer); TELY_Render_PopColourV4(renderer);
@ -3412,13 +3405,16 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
if (game->play.debug_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); };
// NOTE: Info bar ========================================================================== // NOTE: Info bar ==========================================================================
Dqn_f32 next_y = 10.f;
TELY_RFui_PushLabelColourV4(rfui, TELY_COLOUR_BLACK_V4);
{ {
TELY_RFuiResult info_bar = TELY_RFui_Row(rfui, DQN_STRING8("Info Bar")); TELY_RFuiResult info_bar = TELY_RFui_Row(rfui, DQN_STRING8("Info Bar"));
info_bar.widget->semantic_position[TELY_RFuiAxis_X].kind = TELY_RFuiPositionKind_Absolute; info_bar.widget->semantic_position[TELY_RFuiAxis_X].kind = TELY_RFuiPositionKind_Absolute;
info_bar.widget->semantic_position[TELY_RFuiAxis_X].value = 10.f; info_bar.widget->semantic_position[TELY_RFuiAxis_X].value = next_y;
info_bar.widget->semantic_position[TELY_RFuiAxis_Y].kind = TELY_RFuiPositionKind_Absolute; info_bar.widget->semantic_position[TELY_RFuiAxis_Y].kind = TELY_RFuiPositionKind_Absolute;
info_bar.widget->semantic_position[TELY_RFuiAxis_Y].value = 10.f; info_bar.widget->semantic_position[TELY_RFuiAxis_Y].value = next_y;
TELY_RFui_PushParent(rfui, info_bar.widget); TELY_RFui_PushParent(rfui, info_bar.widget);
DQN_DEFER { TELY_RFui_PopParent(rfui); }; DQN_DEFER { TELY_RFui_PopParent(rfui); };
@ -3449,13 +3445,53 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
} }
// NOTE: Other next_y += TELY_Asset_GetFont(assets, TELY_RFui_ActiveFont(rfui))->pixel_height;
{
TELY_RFuiResult bar = TELY_RFui_Column(rfui, DQN_STRING8("Memory bar"));
bar.widget->semantic_position[TELY_RFuiAxis_X].kind = TELY_RFuiPositionKind_Absolute;
bar.widget->semantic_position[TELY_RFuiAxis_X].value = 10.f;
bar.widget->semantic_position[TELY_RFuiAxis_Y].kind = TELY_RFuiPositionKind_Absolute;
bar.widget->semantic_position[TELY_RFuiAxis_Y].value = next_y;
TELY_RFui_PushParent(rfui, bar.widget);
DQN_DEFER { TELY_RFui_PopParent(rfui); };
{
Dqn_ArenaInfo arena_info = Dqn_Arena_Info(&platform->arena);
TELY_RFui_TextF(rfui,
"Platform Arena[%I64u]: %_$$d/%_$$d (HWM %_$$d, COMMIT %_$$d)",
platform->arena.blocks,
arena_info.used,
arena_info.capacity,
arena_info.used_hwm,
arena_info.commit);
next_y += TELY_Asset_GetFont(assets, TELY_RFui_ActiveFont(rfui))->pixel_height;
}
for (Dqn_ArenaCatalogItem *item = g_dqn_library->arena_catalog.sentinel.next; item != &g_dqn_library->arena_catalog.sentinel; item = item->next) {
if (item != g_dqn_library->arena_catalog.sentinel.next)
next_y += TELY_Asset_GetFont(assets, TELY_RFui_ActiveFont(rfui))->pixel_height;
Dqn_Arena *arena = item->arena;
Dqn_ArenaInfo arena_info = Dqn_Arena_Info(arena);
TELY_RFui_TextF(rfui,
"%.*s[%I64u]: %_$$d/%_$$d (HWM %_$$d, COMMIT %_$$d)",
DQN_STRING_FMT(arena->label),
arena->blocks,
arena_info.used,
arena_info.capacity,
arena_info.used_hwm,
arena_info.commit);
}
}
// NOTE: Profiler
next_y += TELY_Asset_GetFont(assets, TELY_RFui_ActiveFont(rfui))->pixel_height;
{ {
TELY_RFuiResult profiler_layout = TELY_RFui_Column(rfui, DQN_STRING8("Profiler Bar")); TELY_RFuiResult profiler_layout = TELY_RFui_Column(rfui, DQN_STRING8("Profiler Bar"));
profiler_layout.widget->semantic_position[TELY_RFuiAxis_X].kind = TELY_RFuiPositionKind_Absolute; profiler_layout.widget->semantic_position[TELY_RFuiAxis_X].kind = TELY_RFuiPositionKind_Absolute;
profiler_layout.widget->semantic_position[TELY_RFuiAxis_X].value = 10.f; profiler_layout.widget->semantic_position[TELY_RFuiAxis_X].value = 10.f;
profiler_layout.widget->semantic_position[TELY_RFuiAxis_Y].kind = TELY_RFuiPositionKind_Absolute; profiler_layout.widget->semantic_position[TELY_RFuiAxis_Y].kind = TELY_RFuiPositionKind_Absolute;
profiler_layout.widget->semantic_position[TELY_RFuiAxis_Y].value = TELY_Asset_GetFont(assets, TELY_RFui_ActiveFont(rfui))->pixel_height * 1.5f; profiler_layout.widget->semantic_position[TELY_RFuiAxis_Y].value = next_y;
TELY_RFui_PushParent(rfui, profiler_layout.widget); TELY_RFui_PushParent(rfui, profiler_layout.widget);
DQN_DEFER { TELY_RFui_PopParent(rfui); }; DQN_DEFER { TELY_RFui_PopParent(rfui); };
@ -3488,6 +3524,8 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
} }
} }
} }
TELY_RFui_Flush(rfui, renderer, input, assets);
} }
if (game->play.state == FP_GameState_Play) { if (game->play.state == FP_GameState_Play) {
@ -3507,9 +3545,10 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F7 Increase stamina"); draw_p.y += TELY_Render_FontHeight(renderer, assets); TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F7 Increase stamina"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F8 Increase mobile data"); draw_p.y += TELY_Render_FontHeight(renderer, assets); TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F8 Increase mobile data"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F9 %s god mode", game->play.god_mode ? "Disable" : "Enable"); draw_p.y += TELY_Render_FontHeight(renderer, assets); TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F9 %s god mode", game->play.god_mode ? "Disable" : "Enable"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F10 %s noclip", player->flags & FP_GameEntityFlag_NoClip ? "Disable" : "Enable"); draw_p.y += TELY_Render_FontHeight(renderer, assets); TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F10 %s noclip", player->flags & FP_GameEntityFlag_NoClip ? "Disable" : "Enable"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F11 Building inventory +1"); draw_p.y += TELY_Render_FontHeight(renderer, assets); TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F11 Building inventory +1"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F12 %s by enemies", player->faction == FP_GameEntityFaction_Nil ? "Attacked" : "Ignored"); draw_p.y += TELY_Render_FontHeight(renderer, assets); TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F12 %s by enemies", player->faction == FP_GameEntityFaction_Nil ? "Attacked" : "Ignored"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " 1 %s HUD", game->play.debug_hide_hud ? "Show" : "Hide"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_PopFont(renderer); TELY_Render_PopFont(renderer);
TELY_Render_PopColourV4(renderer); TELY_Render_PopColourV4(renderer);
@ -3531,9 +3570,10 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
FP_PlayReset(game, platform); FP_PlayReset(game, platform);
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F6)) { if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F6)) {
if (!FP_Game_IsNilEntity(player)) if (!FP_Game_IsNilEntity(player)) {
player->hp_cap += FP_DEFAULT_DAMAGE; player->hp_cap += FP_DEFAULT_DAMAGE;
player->hp = player->hp_cap; player->hp = player->hp_cap;
}
} }
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F7)) { if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F7)) {
@ -3568,6 +3608,9 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer,
? FP_GameEntityFaction_Friendly ? FP_GameEntityFaction_Friendly
: FP_GameEntityFaction_Nil; : FP_GameEntityFaction_Nil;
} }
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_1))
game->play.debug_hide_hud = !game->play.debug_hide_hud;
} }
} }
@ -3579,7 +3622,6 @@ void TELY_DLL_FrameUpdate(void *user_data)
TELY_Assets *assets = &platform->assets; TELY_Assets *assets = &platform->assets;
TELY_Renderer *renderer = &platform->renderer; TELY_Renderer *renderer = &platform->renderer;
FP_Game *game = DQN_CAST(FP_Game *) platform->user_data; FP_Game *game = DQN_CAST(FP_Game *) platform->user_data;
TELY_RFui *rfui = &game->rfui;
// ============================================================================================= // =============================================================================================
@ -3638,6 +3680,5 @@ void TELY_DLL_FrameUpdate(void *user_data)
FP_Render(game, platform, renderer, audio); FP_Render(game, platform, renderer, audio);
TELY_RFui_Flush(rfui, renderer, input, assets);
TELY_Audio_MixPlaybackSamples(audio, assets); TELY_Audio_MixPlaybackSamples(audio, assets);
} }

View File

@ -341,8 +341,9 @@ int main(int argc, char const **argv)
} }
// NOTE: raylib emscripten ===================================================================== // NOTE: raylib emscripten =====================================================================
bool target_web = false;
uint64_t raylib_emscripten_timings[2] = {}; uint64_t raylib_emscripten_timings[2] = {};
if (0) { if (target_web) {
raylib_emscripten_timings[0] = Dqn_OS_PerfCounterNow(); raylib_emscripten_timings[0] = Dqn_OS_PerfCounterNow();
DQN_DEFER { raylib_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); }; DQN_DEFER { raylib_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); };
@ -398,7 +399,7 @@ int main(int argc, char const **argv)
// NOTE: feely pona emscripten ================================================================= // NOTE: feely pona emscripten =================================================================
uint64_t feely_pona_emscripten_timings[2] = {}; uint64_t feely_pona_emscripten_timings[2] = {};
if (0) { if (target_web) {
feely_pona_emscripten_timings[0] = Dqn_OS_PerfCounterNow(); feely_pona_emscripten_timings[0] = Dqn_OS_PerfCounterNow();
DQN_DEFER { feely_pona_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); }; DQN_DEFER { feely_pona_emscripten_timings[1] = Dqn_OS_PerfCounterNow(); };
@ -409,16 +410,15 @@ int main(int argc, char const **argv)
}); });
build_context.compile_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, { build_context.compile_flags = Dqn_Slice_InitCArrayCopy(scratch.arena, {
DQN_STRING8("cmd"), DQN_STRING8("cmd"), DQN_STRING8("/C"), DQN_STRING8("emcc.bat"),
DQN_STRING8("/C"), DQN_STRING8("-o"), DQN_STRING8("feely_pona.html"),
DQN_STRING8("emcc.bat"),
DQN_STRING8("-o"),
DQN_STRING8("feely_pona.html"),
DQN_STRING8("-Os"), // Optimize for size DQN_STRING8("-Os"), // Optimize for size
DQN_STRING8("-Wall"), DQN_STRING8("-Wall"),
Dqn_FsPath_ConvertF(scratch.arena, "%.*s/libraylib.a", DQN_STRING_FMT(build_dir)), Dqn_FsPath_ConvertF(scratch.arena, "%.*s/libraylib.a", DQN_STRING_FMT(build_dir)),
DQN_STRING8("-s"), DQN_STRING8("-s"), DQN_STRING8("USE_GLFW=3"),
DQN_STRING8("USE_GLFW=3"), DQN_STRING8("-s"), DQN_STRING8("ASSERTIONS=1"),
DQN_STRING8("-s"), DQN_STRING8("TOTAL_MEMORY=67108864"),
DQN_STRING8("--preload-file"), DQN_STRING8("Data"),
DQN_STRING8("-msimd128"), DQN_STRING8("-msimd128"),
DQN_STRING8("-msse2"), DQN_STRING8("-msse2"),
}); });

View File

@ -897,6 +897,9 @@ static void FP_Game_EntityTransitionState(FP_Game *game, FP_GameEntity *entity,
case FP_EntityType_MerchantTerry: case FP_EntityType_MerchantTerry:
case FP_EntityType_PhoneMessageProjectile: case FP_EntityType_PhoneMessageProjectile:
case FP_EntityType_Count: break; case FP_EntityType_Count: break;
case FP_EntityType_AirportTerryPlane:
case FP_EntityType_MobSpawner:
case FP_EntityType_PortalMonkey: break;
} }
// NOTE: If no returns are hit above we proceed with the state change // NOTE: If no returns are hit above we proceed with the state change
entity->action.next_state = desired_state; entity->action.next_state = desired_state;

View File

@ -45,15 +45,16 @@ struct FP_GameShape
TELY_RenderShapeMode render_mode; TELY_RenderShapeMode render_mode;
}; };
const uint64_t FP_GAME_ENTITY_HANDLE_GENERATION_MASK = 0xFFFF'0000'0000'0000; const Dqn_usize FP_GAME_ENTITY_HANDLE_GENERATION_MASK_BIT_COUNT = 16;
const uint64_t FP_GAME_ENTITY_HANDLE_GENERATION_RSHIFT = 48; const Dqn_usize FP_GAME_ENTITY_HANDLE_INDEX_MASK = DQN_USIZE_MAX >> FP_GAME_ENTITY_HANDLE_GENERATION_MASK_BIT_COUNT;
const uint64_t FP_GAME_ENTITY_HANDLE_GENERATION_MAX = FP_GAME_ENTITY_HANDLE_GENERATION_MASK >> FP_GAME_ENTITY_HANDLE_GENERATION_RSHIFT; const Dqn_usize FP_GAME_ENTITY_HANDLE_INDEX_MAX = FP_GAME_ENTITY_HANDLE_INDEX_MASK;
const Dqn_usize FP_GAME_ENTITY_HANDLE_GENERATION_MASK = ~FP_GAME_ENTITY_HANDLE_INDEX_MASK;
const Dqn_usize FP_GAME_ENTITY_HANDLE_GENERATION_RSHIFT = (sizeof(Dqn_usize) * 8) - FP_GAME_ENTITY_HANDLE_GENERATION_MASK_BIT_COUNT;
const Dqn_usize FP_GAME_ENTITY_HANDLE_GENERATION_MAX = FP_GAME_ENTITY_HANDLE_GENERATION_MASK >> FP_GAME_ENTITY_HANDLE_GENERATION_RSHIFT;
const uint64_t FP_GAME_ENTITY_HANDLE_INDEX_MASK = 0x0000'FFFF'FFFF'FFFF;
const uint64_t FP_GAME_ENTITY_HANDLE_INDEX_MAX = FP_GAME_ENTITY_HANDLE_INDEX_MASK;
struct FP_GameEntityHandle struct FP_GameEntityHandle
{ {
uint64_t id; Dqn_usize id;
}; };
enum FP_GameWaypointArrive enum FP_GameWaypointArrive
@ -334,6 +335,7 @@ struct FP_GamePlay
Dqn_PCG32 rng; Dqn_PCG32 rng;
bool debug_ui; bool debug_ui;
bool debug_hide_hud;
bool god_mode; bool god_mode;
FP_GameInGameMenu in_game_menu; FP_GameInGameMenu in_game_menu;
bool build_mode_can_place_building; bool build_mode_can_place_building;

View File

@ -55,6 +55,10 @@ DQN_GCC_WARNING_POP
DQN_MSVC_WARNING_PUSH DQN_MSVC_WARNING_PUSH
DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with internal linkage has been removed DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with internal linkage has been removed
DQN_GCC_WARNING_PUSH
DQN_GCC_WARNING_DISABLE(-Wunused-function)
#include "External/tely/tely_profile.h" #include "External/tely/tely_profile.h"
#include "External/tely/tely_platform_input.h" #include "External/tely/tely_platform_input.h"
#include "External/tely/tely_tools.h" #include "External/tely/tely_tools.h"
@ -84,11 +88,15 @@ DQN_MSVC_WARNING_DISABLE(4505) // warning C4505: unreferenced function with inte
#include "feely_pona_entity_create.cpp" #include "feely_pona_entity_create.cpp"
#include "feely_pona_misc.cpp" #include "feely_pona_misc.cpp"
#include "feely_pona.cpp" #include "feely_pona.cpp"
DQN_MSVC_WARNING_POP
DQN_GCC_WARNING_POP
#if defined(DQN_PLATFORM_EMSCRIPTEN)
#include <emscripten.h>
#endif
// NOTE: TELY_Platform ============================================================================= // NOTE: TELY_Platform =============================================================================
#define TELY_PLATFORM_NO_DLL #define TELY_PLATFORM_NO_DLL
#include "External/tely/tely_platform.cpp" #include "External/tely/tely_platform.cpp"
#include "External/tely/tely_platform_raylib.cpp" #include "External/tely/tely_platform_raylib.cpp"
DQN_MSVC_WARNING_POP