diff --git a/External/tely b/External/tely index e1f1112..e1292c1 160000 --- a/External/tely +++ b/External/tely @@ -1 +1 @@ -Subproject commit e1f11120a2a3a2673317db52d73ae30a71faf172 +Subproject commit e1292c1397fad6584b16e79ca63f1596868be9c0 diff --git a/feely_pona.cpp b/feely_pona.cpp index 782a7cd..57599ef 100644 --- a/feely_pona.cpp +++ b/feely_pona.cpp @@ -2052,7 +2052,7 @@ static void FP_Update(TELY_Platform *platform, FP_Game *game, TELY_PlatformInput } // NOTE: Mob spawner ======================================================================= - if (entity->type == FP_EntityType_MobSpawner) { + if (entity->type == FP_EntityType_MobSpawner && 0) { // NOTE: Flush any spawn entities that are dead for (FP_SentinelListLink *link = nullptr; FP_SentinelList_Iterate(&entity->spawn_list, &link); ) { FP_GameEntity *spawned_entity = FP_Game_GetEntity(game, link->data); @@ -2774,7 +2774,7 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren } // NOTE: Render attack box ================================================================= - { + if (!game->play.debug_hide_bounding_rectangles) { Dqn_FArray attack_boxes = FP_Game_CalcEntityMeleeAttackBoxes(game, entity->handle); for (Dqn_Rect box : attack_boxes) TELY_Render_RectColourV4(renderer, box, TELY_RenderShapeMode_Line, TELY_COLOUR_RED_TOMATO_V4); @@ -2784,12 +2784,14 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren TELY_Render_CircleColourV4(renderer, world_pos, 4.f, TELY_RenderShapeMode_Fill, TELY_COLOUR_RED_TOMATO_V4); // NOTE: Render hot/active entity ========================================================== - if (game->play.clicked_entity == entity->handle) { - TELY_Render_RectColourV4(renderer, world_hit_box, TELY_RenderShapeMode_Line, TELY_COLOUR_WHITE_PALE_GOLDENROD_V4); + if (!game->play.debug_hide_bounding_rectangles) { + if (game->play.clicked_entity == entity->handle) { + TELY_Render_RectColourV4(renderer, world_hit_box, TELY_RenderShapeMode_Line, TELY_COLOUR_WHITE_PALE_GOLDENROD_V4); - } else if (game->play.hot_entity == entity->handle || (entity->flags & FP_GameEntityFlag_DrawHitBox)) { - Dqn_V4 hot_colour = game->play.hot_entity == entity->handle ? TELY_COLOUR_RED_TOMATO_V4 : TELY_Colour_V4Alpha(TELY_COLOUR_YELLOW_SANDY_V4, .5f); - TELY_Render_RectColourV4(renderer, world_hit_box, TELY_RenderShapeMode_Line, hot_colour); + } else if (game->play.hot_entity == entity->handle || (entity->flags & FP_GameEntityFlag_DrawHitBox)) { + Dqn_V4 hot_colour = game->play.hot_entity == entity->handle ? TELY_COLOUR_RED_TOMATO_V4 : TELY_Colour_V4Alpha(TELY_COLOUR_YELLOW_SANDY_V4, .5f); + TELY_Render_RectColourV4(renderer, world_hit_box, TELY_RenderShapeMode_Line, hot_colour); + } } if (game->play.hot_entity == entity->handle) { @@ -3975,6 +3977,9 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren // NOTE: Debug UI ============================================================================== + if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F1)) + game->play.debug_ui = !game->play.debug_ui; + DQN_MSVC_WARNING_PUSH DQN_MSVC_WARNING_DISABLE(4127) // Conditional expression is constant 'FP_DEVELOPER_MODE' if (FP_DEVELOPER_MODE && game->play.debug_ui) { @@ -3987,39 +3992,110 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren 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")); - info_bar.widget->semantic_position[TELY_RFuiAxis_X].kind = TELY_RFuiPositionKind_Absolute; - 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].value = next_y; - - TELY_RFui_PushParent(rfui, info_bar.widget); + TELY_RFuiResult info_column = TELY_RFui_ColumnReverse(rfui, DQN_STRING8("Info Column")); + TELY_RFui_PushParent(rfui, info_column.widget); DQN_DEFER { TELY_RFui_PopParent(rfui); }; - Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr); - TELY_RFui_TextF(rfui, "TELY"); - if (Dqn_String8_IsValid(platform->core.os_name)) { - TELY_RFui_TextF(rfui, " | %.*s", DQN_STRING_FMT(platform->core.os_name)); + info_column.widget->semantic_position[TELY_RFuiAxis_X].kind = TELY_RFuiPositionKind_Absolute; + info_column.widget->semantic_position[TELY_RFuiAxis_X].value = next_y; + info_column.widget->semantic_position[TELY_RFuiAxis_Y].kind = TELY_RFuiPositionKind_Absolute; + info_column.widget->semantic_position[TELY_RFuiAxis_Y].value = platform->core.window_size.h - TELY_Render_FontHeight(renderer, assets); + + { + TELY_RFuiResult row = TELY_RFui_Row(rfui, DQN_STRING8("Info Bar")); + TELY_RFui_PushParent(rfui, row.widget); + DQN_DEFER { TELY_RFui_PopParent(rfui); }; + + Dqn_ThreadScratch scratch = Dqn_Thread_GetScratch(nullptr); + TELY_RFui_TextF(rfui, "TELY"); + if (Dqn_String8_IsValid(platform->core.os_name)) { + TELY_RFui_TextF(rfui, " | %.*s", DQN_STRING_FMT(platform->core.os_name)); + } + + TELY_RFui_TextF(rfui, + " | %dx%d %.1fHz | TSC %.1f GHz", + platform->core.window_size.w, + platform->core.window_size.h, + platform->core.display.refresh_rate, + platform->core.tsc_per_second / 1'000'000'000.0); + + if (platform->core.ram_mb) + TELY_RFui_TextF(rfui, " | RAM %.1fGB", platform->core.ram_mb / 1024.0); + + TELY_RFui_TextF(rfui, + " | Work %04.1fms/f (%04.1f%%) | %05.1f FPS | Frame %'I64u | Timer %.1fs", + input->work_ms, + input->work_ms * 100.0 / input->delta_ms, + 1000.0 / input->delta_ms, + input->frame_counter, + input->timer_s); } - TELY_RFui_TextF(rfui, - " | %dx%d %.1fHz | TSC %.1f GHz", - platform->core.window_size.w, - platform->core.window_size.h, - platform->core.display.refresh_rate, - platform->core.tsc_per_second / 1'000'000'000.0); + TELY_RFui_TextF(rfui, "Mouse: %.1f, %.1f", input->mouse_p.x, input->mouse_p.y); + TELY_RFui_TextF(rfui, "Camera: %.1f, %.1f", game->play.camera.world_pos.x, game->play.camera.world_pos.y); + TELY_RFui_TextF(rfui, "Debug Info"); - if (platform->core.ram_mb) - TELY_RFui_TextF(rfui, " | RAM %.1fGB", platform->core.ram_mb / 1024.0); + if (TELY_RFui_ButtonF(rfui, " F1 Debug info").clicked) + game->play.debug_ui = !game->play.debug_ui; - TELY_RFui_TextF(rfui, - " | Work %04.1fms/f (%04.1f%%) | %05.1f FPS | Frame %'I64u | Timer %.1fs", - input->work_ms, - input->work_ms * 100.0 / input->delta_ms, - 1000.0 / input->delta_ms, - input->frame_counter, - input->timer_s); + if (TELY_RFui_ButtonF(rfui, " F2 Add coins x10,000").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F2)) { + for (FP_GameEntityHandle player_handle : game->play.players) { + FP_GameEntity *player = FP_Game_GetEntity(game, player_handle); + player->coins += 10'000; + } + } + if (TELY_RFui_ButtonF(rfui, " F3 Win game").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F3)) + game->play.state = FP_GameState_WinGame; + + if (TELY_RFui_ButtonF(rfui, " F4 Lose game").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F4)) + game->play.state = FP_GameState_LoseGame; + + if (TELY_RFui_ButtonF(rfui, " F5 Reset game").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F5)) + FP_PlayReset(game, platform); + + if (TELY_RFui_ButtonF(rfui, " F6 Increase health").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F6)) { + for (FP_GameEntityHandle player_handle : game->play.players) { + FP_GameEntity *player = FP_Game_GetEntity(game, player_handle); + player->hp_cap += FP_DEFAULT_DAMAGE; + player->hp = player->hp_cap; + } + } + + if (TELY_RFui_ButtonF(rfui, " F7 Increase stamina").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F7)) { + for (FP_GameEntityHandle player_handle : game->play.players) { + FP_GameEntity *player = FP_Game_GetEntity(game, player_handle); + player->stamina_cap += DQN_CAST(uint16_t)(FP_TERRY_DASH_STAMINA_COST * .5f); + player->stamina = player->stamina_cap; + } + } + + if (TELY_RFui_ButtonF(rfui, " F8 Increase mobile data").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F8)) { + for (FP_GameEntityHandle player_handle : game->play.players) { + FP_GameEntity *player = FP_Game_GetEntity(game, player_handle); + player->terry_mobile_data_plan_cap += DQN_KILOBYTES(1); + player->terry_mobile_data_plan = player->terry_mobile_data_plan_cap; + } + } + + if (TELY_RFui_ButtonF(rfui, " F9 %s god mode", game->play.god_mode ? "Disable" : "Enable").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F9)) + game->play.god_mode = !game->play.god_mode; + + if (TELY_RFui_ButtonF(rfui, " F11 Building inventory +1").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F11)) { + for (FP_GameEntityHandle player_handle : game->play.players) { + FP_GameEntity *player = FP_Game_GetEntity(game, player_handle); + player->inventory.clubs += 1; + player->inventory.airports += 1; + player->inventory.churchs += 1; + player->inventory.kennels += 1; + } + } + + if (TELY_RFui_ButtonF(rfui, " 1 %s HUD", game->play.debug_hide_hud ? "Show" : "Hide").clicked || TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_1)) + game->play.debug_hide_hud = !game->play.debug_hide_hud; + + if (TELY_RFui_ButtonF(rfui, "%s bounding rects", game->play.debug_hide_bounding_rectangles ? "Show" : "Hide").clicked) + game->play.debug_hide_bounding_rectangles = !game->play.debug_hide_bounding_rectangles; } if (0) { @@ -4062,8 +4138,8 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren } // NOTE: Profiler - next_y += TELY_Asset_GetFont(assets, TELY_RFui_ActiveFont(rfui))->pixel_height; - { + if (0) { + next_y += TELY_Asset_GetFont(assets, TELY_RFui_ActiveFont(rfui))->pixel_height; 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].value = 10.f; @@ -4073,9 +4149,6 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren TELY_RFui_PushParent(rfui, profiler_layout.widget); DQN_DEFER { TELY_RFui_PopParent(rfui); }; - TELY_RFui_TextF(rfui, "Camera: %.1f, %.1f", game->play.camera.world_pos.x, game->play.camera.world_pos.y); - TELY_RFui_TextF(rfui, "Mouse: %.1f, %.1f", input->mouse_p.x, input->mouse_p.y); - // TODO(doyle): On emscripten we need to use Dqn_OS_PerfCounterNow() however those // require OS functions which need to be exposed into the platform layer. #if 0 @@ -4110,90 +4183,6 @@ static void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *ren TELY_RFui_Flush(rfui, renderer, input, assets); } - - DQN_MSVC_WARNING_PUSH - DQN_MSVC_WARNING_DISABLE(4127) // Conditional expression is constant 'FP_DEVELOPER_MODE' - if (FP_DEVELOPER_MODE && game->play.state == FP_GameState_Play) { - DQN_MSVC_WARNING_POP - TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity()); - DQN_DEFER { TELY_Render_PopTransform(renderer); }; - - Dqn_V2 draw_p = Dqn_V2_InitNx2(32.f, platform->core.window_size.h * .5f); - TELY_Render_PushFont(renderer, game->inter_regular_font); - TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, "DEBUG MENU"); draw_p.y += TELY_Render_FontHeight(renderer, assets); - TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F1 Debug info"); draw_p.y += TELY_Render_FontHeight(renderer, assets); - TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F2 Add coins x10,000"); draw_p.y += TELY_Render_FontHeight(renderer, assets); - TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F3 Win game"); draw_p.y += TELY_Render_FontHeight(renderer, assets); - TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F4 Lose game"); draw_p.y += TELY_Render_FontHeight(renderer, assets); - TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F5 Reset game"); draw_p.y += TELY_Render_FontHeight(renderer, assets); - TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F6 Increase health"); 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, " 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, " F11 Building inventory +1"); 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_PopColourV4(renderer); - - if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F1)) - game->play.debug_ui = !game->play.debug_ui; - - if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F2)) { - for (FP_GameEntityHandle player_handle : game->play.players) { - FP_GameEntity *player = FP_Game_GetEntity(game, player_handle); - player->coins += 10'000; - } - } - - if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F3)) - game->play.state = FP_GameState_WinGame; - - if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F4)) - game->play.state = FP_GameState_LoseGame; - - if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F5)) - FP_PlayReset(game, platform); - - if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F6)) { - for (FP_GameEntityHandle player_handle : game->play.players) { - FP_GameEntity *player = FP_Game_GetEntity(game, player_handle); - player->hp_cap += FP_DEFAULT_DAMAGE; - player->hp = player->hp_cap; - } - } - - if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F7)) { - for (FP_GameEntityHandle player_handle : game->play.players) { - FP_GameEntity *player = FP_Game_GetEntity(game, player_handle); - player->stamina_cap += DQN_CAST(uint16_t)(FP_TERRY_DASH_STAMINA_COST * .5f); - player->stamina = player->stamina_cap; - } - } - - if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F8)) { - for (FP_GameEntityHandle player_handle : game->play.players) { - FP_GameEntity *player = FP_Game_GetEntity(game, player_handle); - player->terry_mobile_data_plan_cap += DQN_KILOBYTES(1); - player->terry_mobile_data_plan = player->terry_mobile_data_plan_cap; - } - } - - if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F9)) - game->play.god_mode = !game->play.god_mode; - - if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F11)) { - for (FP_GameEntityHandle player_handle : game->play.players) { - FP_GameEntity *player = FP_Game_GetEntity(game, player_handle); - player->inventory.clubs += 1; - player->inventory.airports += 1; - player->inventory.churchs += 1; - player->inventory.kennels += 1; - } - } - - if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_1)) - game->play.debug_hide_hud = !game->play.debug_hide_hud; - } } FP_DLL_FUNCTION diff --git a/feely_pona_game.h b/feely_pona_game.h index 9b620e1..f703baa 100644 --- a/feely_pona_game.h +++ b/feely_pona_game.h @@ -405,6 +405,7 @@ struct FP_GamePlay bool debug_ui; bool debug_hide_hud; + bool debug_hide_bounding_rectangles; bool god_mode; Dqn_FArray mob_spawners;