From 0e4dbfd9f744daca718b13357536525163cbc9c4 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 21 Jan 2024 23:49:40 -0600 Subject: [PATCH] Add in arrow indicators for accessible locations on the overworld stage map. Move saving of the game to overworld map state change event. --- .../State_LevelComplete.cpp | 1 - Adventures in Lestoria/State_OverworldMap.cpp | 51 ++++++++++++++---- Adventures in Lestoria/TODO.txt | 3 ++ Adventures in Lestoria/Unlock.cpp | 9 ---- Adventures in Lestoria/Version.h | 2 +- .../assets/Campaigns/World_Map.tmx | 2 - .../assets/config/gfx/gfx.txt | 2 + Adventures in Lestoria/assets/exclamation.png | Bin 0 -> 589 bytes .../assets/overworld_arrow.png | Bin 0 -> 584 bytes Adventures in Lestoria/util.h | 14 +++++ 10 files changed, 61 insertions(+), 23 deletions(-) create mode 100644 Adventures in Lestoria/assets/exclamation.png create mode 100644 Adventures in Lestoria/assets/overworld_arrow.png diff --git a/Adventures in Lestoria/State_LevelComplete.cpp b/Adventures in Lestoria/State_LevelComplete.cpp index 1cd082cb..b28ea1de 100644 --- a/Adventures in Lestoria/State_LevelComplete.cpp +++ b/Adventures in Lestoria/State_LevelComplete.cpp @@ -52,7 +52,6 @@ void State_LevelComplete::OnStateChange(GameState*prevState){ Component(MenuType::LEVEL_COMPLETE,"Level EXP Gain Outline")->SetLabel(std::format("+{} Exp",game->GetPlayer()->GetAccumulatedXP())); game->GetPlayer()->AddXP(game->GetPlayer()->GetAccumulatedXP()); game->GetPlayer()->SetState(State::NORMAL); - SaveFile::SaveGame(); Menu::OpenMenu(LEVEL_COMPLETE); }; void State_LevelComplete::OnUserUpdate(AiL*game){ diff --git a/Adventures in Lestoria/State_OverworldMap.cpp b/Adventures in Lestoria/State_OverworldMap.cpp index 1fcad1d8..ca9ead7f 100644 --- a/Adventures in Lestoria/State_OverworldMap.cpp +++ b/Adventures in Lestoria/State_OverworldMap.cpp @@ -51,6 +51,7 @@ All rights reserved. INCLUDE_MONSTER_LIST INCLUDE_game +INCLUDE_GFX std::vectorState_OverworldMap::connections; ConnectionPoint*State_OverworldMap::currentConnectionPoint=nullptr; @@ -59,6 +60,7 @@ State_OverworldMap::State_OverworldMap(){ SetStageMarker("Stage I-I"); //Eventually we will load the game from a file and this will not be necessary. We just set it to this for now. } void State_OverworldMap::OnStateChange(GameState*prevState){ + SaveFile::SaveGame(); game->LoadLevel("WORLD_MAP"); if(Menu::IsMenuOpen()){ Menu::CloseAllMenus(); @@ -186,16 +188,45 @@ void State_OverworldMap::Draw(AiL*game){ break; } } - #pragma region Audio Test - std::stringstream eventText; - eventText<<"Event Set to: "; - eventText<DrawShadowStringPropDecal({2,game->ScreenHeight()-36.f},eventText.str(),{255,255,255,uint8_t(util::lerp(255,0,lastEventTime/5.0f))},{0,0,0,uint8_t(util::lerp(255,0,lastEventTime/5.0f))}); - if(lastAudioTime!=5.0f)game->DrawShadowStringPropDecal({2,game->ScreenHeight()-20.f},audioText.str(),{255,255,255,uint8_t(util::lerp(255,0,lastAudioTime/5.0f))},{0,0,0,uint8_t(util::lerp(255,0,lastAudioTime/5.0f))}); - #pragma endregion + + //In radians. + using AngleTotal=float; + using Count=uint8_t; + using MedianAngle=std::pair; + using ConnectionPointIndex=float; + + auto GetAngle=[](MedianAngle angle){ + return angle.first/angle.second; + }; + + std::mapneighbors; + + for(int direction=0;int index:currentConnectionPoint->neighbors){ + if(index!=-1){ + ConnectionPoint&neighbor=connections[index]; + if(!Unlock::IsUnlocked(neighbor)){ + direction++; + continue; + } + + float arrowAngle=direction*0.5f*PI-0.5f*PI; + if(neighbors.count(index)){ + if(arrowAngle==0.f)neighbors[index].first+=2*PI; + neighbors[index].first+=circ_add(0,2*PI+arrowAngle,0,2*PI); + neighbors[index].second++; + }else{ + neighbors[index]={circ_add(0,arrowAngle,0,2*PI),1}; + } + } + direction++; + } + + float arrowDist=fmod(game->GetRuntime(),1.0f)<0.5f?14:18; + + for(auto&[index,medianAngle]:neighbors){ + game->view.DrawRotatedDecal(game->GetPlayer()->GetPos()+vf2d{arrowDist,GetAngle(medianAngle)}.cart()+vf2d{0.f,1.f},GFX["overworld_arrow.png"].Decal(),GetAngle(medianAngle),GFX["overworld_arrow.png"].Sprite()->Size()/2,{1.f,1.f},{0,0,0}); + game->view.DrawRotatedDecal(game->GetPlayer()->GetPos()+vf2d{arrowDist,GetAngle(medianAngle)}.cart(),GFX["overworld_arrow.png"].Decal(),GetAngle(medianAngle),GFX["overworld_arrow.png"].Sprite()->Size()/2,{1.f,1.f},{199,48,55}); + } }; void State_OverworldMap::SetStageMarker(std::string connectionName){ for(ConnectionPoint&connection:connections){ diff --git a/Adventures in Lestoria/TODO.txt b/Adventures in Lestoria/TODO.txt index 9161200e..99d553ac 100644 --- a/Adventures in Lestoria/TODO.txt +++ b/Adventures in Lestoria/TODO.txt @@ -13,6 +13,7 @@ Settings Menu - Fix Stage Completed screen, item displays can hit the scrollbar. - Stage Loot Config +- Initial Crafting of Gear. January 31st ============ @@ -37,6 +38,8 @@ ERR messages become just output messages in release build and won't crash the ga - Hide mouse cursor during controller play. Reveal it again during mouse play. - Resource Packs +- Hold mouse down to increase quantity + - Getting hurt has additional effects. diff --git a/Adventures in Lestoria/Unlock.cpp b/Adventures in Lestoria/Unlock.cpp index c78129ef..95a04560 100644 --- a/Adventures in Lestoria/Unlock.cpp +++ b/Adventures in Lestoria/Unlock.cpp @@ -42,15 +42,6 @@ std::setUnlock::unlocks; void Unlock::Initialize(){ UnlockArea("WORLD_MAP"); - UnlockArea("CAMPAIGN_1_1"); - UnlockArea("BOSS_1"); - UnlockArea("CAMPAIGN_1_2"); - UnlockArea("CAMPAIGN_1_3"); - UnlockArea("CAMPAIGN_1_4"); - UnlockArea("CAMPAIGN_1_5"); - UnlockArea("CAMPAIGN_1_6"); - UnlockArea("CAMPAIGN_1_7"); - UnlockArea("CAMPAIGN_1_8"); } void Unlock::UnlockArea(std::string mapName){ diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index ed92f8e4..85fe0182 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 6200 +#define VERSION_BUILD 6212 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/Campaigns/World_Map.tmx b/Adventures in Lestoria/assets/Campaigns/World_Map.tmx index 94647725..9a5f7bd3 100644 --- a/Adventures in Lestoria/assets/Campaigns/World_Map.tmx +++ b/Adventures in Lestoria/assets/Campaigns/World_Map.tmx @@ -663,8 +663,6 @@ - - diff --git a/Adventures in Lestoria/assets/config/gfx/gfx.txt b/Adventures in Lestoria/assets/config/gfx/gfx.txt index 9ca6ef32..87236110 100644 --- a/Adventures in Lestoria/assets/config/gfx/gfx.txt +++ b/Adventures in Lestoria/assets/config/gfx/gfx.txt @@ -60,6 +60,8 @@ Images GFX_Button_Face_L2 = themes/button_l2.png GFX_Button_Face_R1 = themes/button_r1.png GFX_Button_Face_R2 = themes/button_r2.png + GFX_Overworld_Arrow = overworld_arrow.png + GFX_Exclamation = exclamation.png # Ability Icons GFX_Warrior_BattleCry_Icon = Ability Icons/battlecry.png diff --git a/Adventures in Lestoria/assets/exclamation.png b/Adventures in Lestoria/assets/exclamation.png new file mode 100644 index 0000000000000000000000000000000000000000..d52c63b2b6dcc21287900fee992ec64d296babdc GIT binary patch literal 589 zcmV-T0EX>4Tx04R}tkv&MmP!xqv(~2S$2aAX}WN4k*MMWG-6^me@v=v%)FnQ@8G-*gu zTpR`0f`dPcRRz=x)?qWR4yYJ5$Qi>)6d?In2>4rtTK|H%@ z>74h8L#!ex#OK6OgDyz?$aUG}H_l~;1)do)a+!JJ5V2V9VY!D{#ZZZ7h{KAiQNECO zS>e3JS*_CX>@2HM@dakSAh-}0000aNklEX>4Tx04R}tkv&MmP!xqv(~2S$2aAX}WN4k*MMWG-6^me@v=v%)FnQ@8G-*gu zTpR`0f`dPcRRz=x)?qWR4yYJ5$Qi>)6d?In2>4rtTK|H%@ z>74h8L#!ex#OK6OgDyz?$aUG}H_l~;1)do)a+!JJ5V2V9VY!D{#ZZZ7h{KAiQNECO zS>e3JS*_CX>@2HM@dakSAh-}0000VNkl literal 0 HcmV?d00001 diff --git a/Adventures in Lestoria/util.h b/Adventures in Lestoria/util.h index 4545fee0..68b59c51 100644 --- a/Adventures in Lestoria/util.h +++ b/Adventures in Lestoria/util.h @@ -58,5 +58,19 @@ namespace olc::util{ std::u32string WrapText(PixelGameEngine*pge,std::u32string str,int width,Font&font,vd2d scale); } +template +constexpr auto circ_add( + const TL& lhs, + const TR& rhs, + const decltype(lhs + rhs) rmin = 0, + const decltype(lhs + rhs) rmax = 360) +{ + auto c = lhs + rhs; + auto range = rmax - rmin; + while (c >= rmax) c -= range; + while (c < rmin) c += range; + return c; +} + //Converts unit distances to pixels. (Every 100 units = 24 pixels) long double operator""_Pixels(long double unitDist); \ No newline at end of file