From 5652741ec002561836cea21dac144c6ac5db4976 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 19 Nov 2023 15:57:18 -0600 Subject: [PATCH] Added level complete window upon completing a stage. --- Crawler/Crawler.cpp | 21 +++++++++++++++------ Crawler/Crawler.vcxproj | 1 + Crawler/Crawler.vcxproj.filters | 9 ++++++--- Crawler/DEFINES.h | 2 ++ Crawler/LevelCompleteWindow.cpp | 10 ++++++++++ Crawler/Menu.cpp | 1 + Crawler/Menu.h | 3 +++ Crawler/Player.cpp | 22 ++++++++++++++++++++++ Crawler/Player.h | 4 ++++ Crawler/Version.h | 2 +- Crawler/assets/config/Player.txt | 3 +++ 11 files changed, 68 insertions(+), 10 deletions(-) create mode 100644 Crawler/LevelCompleteWindow.cpp diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 08570e6b..50bcdeb4 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -665,12 +665,14 @@ void Crawler::RenderWorld(float fElapsedTime){ auto RenderZone=[&](geom2d::rect&zone){ game->SetDecalMode(DecalMode::ADDITIVE); - Pixel ringColor={64,255,64,uint8_t(abs(sin(game->levelTime))*255)}; + Pixel ringColor={128,128,128,uint8_t(abs(sin(game->levelTime))*255)}; + Decal*ringDecal=GFX["finishring_green.png"].Decal(); if(!player->IsOutOfCombat()){ game->SetDecalMode(DecalMode::NORMAL); ringColor.r=ringColor.g=ringColor.b=64; + ringDecal=GFX["finishring.png"].Decal(); } - view.DrawDecal(zone.pos,GFX["finishring.png"].Decal(),vf2d(zone.size)/vf2d(GFX["finishring.png"].Sprite()->Size()),ringColor); + view.DrawDecal(zone.pos,ringDecal,vf2d(zone.size)/vf2d(GFX["finishring.png"].Sprite()->Size()),ringColor); game->SetDecalMode(DecalMode::NORMAL); }; @@ -1094,17 +1096,24 @@ Player*Crawler::GetPlayer(){ void Crawler::RenderHud(){ RenderCooldowns(); - if(GetPlayer()->GetCastInfo().castTimer>0){ + auto RenderCastbar=[&](const CastInfo&cast){ FillRectDecal(vf2d{ScreenWidth()/2-92.f,ScreenHeight()-90.f},{184,20},BLACK); FillRectDecal(vf2d{ScreenWidth()/2-90.f,ScreenHeight()-88.f},{180,16},DARK_GREY); - float timer=GetPlayer()->GetCastInfo().castTimer; - float totalTime=GetPlayer()->GetCastInfo().castTotalTime; - std::string castText=GetPlayer()->GetCastInfo().name; + float timer=cast.castTimer; + float totalTime=cast.castTotalTime; + std::string castText=cast.name; GradientFillRectDecal(vf2d{ScreenWidth()/2-90.f,ScreenHeight()-88.f},{(timer/totalTime)*180,16},{247,125,37},{247,125,37},{247,184,37},{247,184,37}); std::stringstream castTimeDisplay; castTimeDisplay<GetCastInfo().castTimer>0){ + RenderCastbar(GetPlayer()->GetCastInfo()); + }else + if(GetPlayer()->GetEndZoneStandTime()>0){ + RenderCastbar(CastInfo{"Exiting Level...",GetPlayer()->GetEndZoneStandTime(),"Player.End Zone Wait Time"_F}); } DrawDecal({2,2},GFX["heart.png"].Decal()); diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj index 04f1de43..a76b1a20 100644 --- a/Crawler/Crawler.vcxproj +++ b/Crawler/Crawler.vcxproj @@ -342,6 +342,7 @@ + diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters index f426da3e..1e462b5b 100644 --- a/Crawler/Crawler.vcxproj.filters +++ b/Crawler/Crawler.vcxproj.filters @@ -392,9 +392,6 @@ Source Files\Interface - - Source Files\Interface - Header Files\Interface @@ -422,6 +419,12 @@ Source Files + + Source Files + + + Source Files\Interface + diff --git a/Crawler/DEFINES.h b/Crawler/DEFINES.h index 301f9218..67f0b12d 100644 --- a/Crawler/DEFINES.h +++ b/Crawler/DEFINES.h @@ -49,6 +49,8 @@ SUCH DAMAGE. #define DO_NOTHING [](MenuFuncData data){return true;} #define INCLUDE_LEVEL_NAMES extern safemapLEVEL_NAMES; +#define INCLUDE_CENTERED extern const vf2d Menu::CENTERED; + #define ACCESS_PLAYER Player*p=game->GetPlayer(); #define VARIANTS float,int,std::string,bool,vf2d diff --git a/Crawler/LevelCompleteWindow.cpp b/Crawler/LevelCompleteWindow.cpp new file mode 100644 index 00000000..ee479ee9 --- /dev/null +++ b/Crawler/LevelCompleteWindow.cpp @@ -0,0 +1,10 @@ +#include "Menu.h" +#include "Crawler.h" + +INCLUDE_game + +void Menu::InitializeLevelCompleteWindow(){ + Menu*levelCompleteWindow=Menu::CreateMenu(LEVEL_COMPLETE,{0,0},game->GetScreenSize()); + + +} \ No newline at end of file diff --git a/Crawler/Menu.cpp b/Crawler/Menu.cpp index 5391d713..275d3f4f 100644 --- a/Crawler/Menu.cpp +++ b/Crawler/Menu.cpp @@ -88,6 +88,7 @@ void Menu::InitializeMenus(){ InitializeMainMenuWindow(); InitializeOverworldMapLevelWindow(); InitializeItemLoadoutWindow(); + InitializeLevelCompleteWindow(); for(MenuType type=TEST;type0){ castInfo.castTimer-=fElapsedTime; if(castInfo.castTimer<=0){ @@ -759,4 +762,23 @@ void Player::ResetLastCombatTime(){ bool Player::IsOutOfCombat(){ return lastCombatTime>="Player.Out of Combat Time"_F; +} + +float Player::GetEndZoneStandTime(){ + return endZoneStandTime; +} + +void Player::CheckEndZoneCollision(){ + if(IsOutOfCombat()){ + for(ZoneData&zone:game->MAP_DATA[game->GetCurrentLevel()].ZoneData.at("EndZone")){ + if(zone.isUpper==upperLevel&&geom2d::overlaps(GetPos(),zone.zone)){ + endZoneStandTime+=game->GetElapsedTime(); + if(endZoneStandTime>="Player.End Zone Wait Time"_F){ + Menu::OpenMenu(LEVEL_COMPLETE); + } + return; + } + } + } + endZoneStandTime=0; } \ No newline at end of file diff --git a/Crawler/Player.h b/Crawler/Player.h index 9456325e..c85850e7 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -127,6 +127,7 @@ protected: std::vectorghostPositions; float rapidFireTimer=0; int remainingRapidFireShots=0; + float endZoneStandTime=0; const float RAPID_FIRE_SHOOT_DELAY="Ranger.Ability 1.ArrowDelay"_F; const int RAPID_FIRE_SHOOT_AMOUNT="Ranger.Ability 1.ArrowCount"_I; public: @@ -192,6 +193,7 @@ public: bool OnUpperLevel(); void ResetLastCombatTime(); bool IsOutOfCombat(); + float GetEndZoneStandTime(); //Triggers when the player has moved. void Moved(); virtual ~Player()=default; @@ -213,6 +215,8 @@ public: virtual std::string&GetIdleSAnimation()=0; virtual std::string&GetIdleWAnimation()=0; + void CheckEndZoneCollision(); + CastInfo&GetCastInfo(); void SetAnimationBasedOnTargetingDirection(float targetDirection); diff --git a/Crawler/Version.h b/Crawler/Version.h index f3d3c2c5..b5f0ef96 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -33,7 +33,7 @@ SUCH DAMAGE. #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 1 -#define VERSION_BUILD 2920 +#define VERSION_BUILD 2930 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/assets/config/Player.txt b/Crawler/assets/config/Player.txt index 53c7f675..2f90d64f 100644 --- a/Crawler/assets/config/Player.txt +++ b/Crawler/assets/config/Player.txt @@ -15,6 +15,9 @@ Player # How many seconds must pass before the player is considered out of combat (meaning they can exit a level) Out of Combat Time = 5.0 + # How long the player must stand in the end zone before leaving the level. + End Zone Wait Time = 5.0 + # Each attack will have _N,_E,_S,_W appended to them once read in-game. PLAYER_ANIMATION[0] = WARRIOR_WALK PLAYER_ANIMATION[1] = WARRIOR_IDLE