fp: Reset game on game completion

This commit is contained in:
doyle 2023-10-08 16:17:40 +11:00
parent 1ae76db2f6
commit da41e986c5

View File

@ -2422,6 +2422,9 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, "Press enter to start"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_PopFont(renderer);
TELY_Render_PopColourV4(renderer);
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_Return))
game->play.state = FP_GameState_Play;
} else {
TELY_Render_PushFont(renderer, game->inter_regular_font_large);
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, "Terry has been saved"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
@ -2433,10 +2436,11 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, "Press enter to restart"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_PopFont(renderer);
TELY_Render_PopColourV4(renderer);
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_Return))
FP_PlayReset(game, platform);
}
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_Return))
game->play.state = FP_GameState_Play;
} else {
// NOTE: Render the merchant menus =========================================
FP_GameEntity *player = FP_Game_GetEntity(game, game->play.player);
@ -3087,60 +3091,62 @@ void FP_Render(FP_Game *game, TELY_Platform *platform, TELY_Renderer *renderer)
}
}
TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity());
DQN_DEFER { TELY_Render_PopTransform(renderer); };
if (game->play.state == FP_GameState_Play) {
TELY_Render_PushTransform(renderer, Dqn_M2x3_Identity());
DQN_DEFER { TELY_Render_PopTransform(renderer); };
FP_GameEntity *player = FP_Game_GetEntity(game, game->play.player);
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 Reset game"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F5 Increase health"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F6 Increase stamina"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F7 Increase mobile data"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F8 %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 noclip", player->flags & FP_GameEntityFlag_NoClip ? "Disable" : "Enable"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_PopFont(renderer);
TELY_Render_PopColourV4(renderer);
FP_GameEntity *player = FP_Game_GetEntity(game, game->play.player);
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 Reset game"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F5 Increase health"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F6 Increase stamina"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F7 Increase mobile data"); draw_p.y += TELY_Render_FontHeight(renderer, assets);
TELY_Render_TextF(renderer, draw_p, Dqn_V2_Zero, " F8 %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 noclip", player->flags & FP_GameEntityFlag_NoClip ? "Disable" : "Enable"); 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_F1))
game->play.debug_ui = !game->play.debug_ui;
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F2)) {
if (!FP_Game_IsNilEntity(player))
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))
FP_PlayReset(game, platform);
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F5)) {
if (!FP_Game_IsNilEntity(player))
player->hp_cap += FP_DEFAULT_DAMAGE;
}
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F6)) {
if (!FP_Game_IsNilEntity(player))
player->stamina_cap += DQN_CAST(uint16_t)(FP_TERRY_DASH_STAMINA_COST * .5f);
}
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F7)) {
if (!FP_Game_IsNilEntity(player))
player->terry_mobile_data_plan_cap += DQN_KILOBYTES(1);
}
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F8))
game->play.god_mode = !game->play.god_mode;
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F9))
player->flags ^= FP_GameEntityFlag_NoClip;
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F2)) {
if (!FP_Game_IsNilEntity(player))
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))
FP_PlayReset(game, platform);
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F5)) {
if (!FP_Game_IsNilEntity(player))
player->hp_cap += FP_DEFAULT_DAMAGE;
}
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F6)) {
if (!FP_Game_IsNilEntity(player))
player->stamina_cap += DQN_CAST(uint16_t)(FP_TERRY_DASH_STAMINA_COST * .5f);
}
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F7)) {
if (!FP_Game_IsNilEntity(player))
player->terry_mobile_data_plan_cap += DQN_KILOBYTES(1);
}
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F8))
game->play.god_mode = !game->play.god_mode;
if (TELY_Platform_InputScanCodeIsPressed(input, TELY_PlatformInputScanCode_F9))
player->flags ^= FP_GameEntityFlag_NoClip;
}