diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 6aae16c8..f5f71f7c 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -3385,6 +3385,18 @@ void AiL::DrawPie(vf2d center,float radius,float degreesCut,Pixel col){ DrawPolygonDecal(nullptr,circleCooldownPoints,circleCooldownPoints,std::max(1,int(degreesCut/4)),center,radius,col); } +void AiL::DrawPieArc(const std::string_view texture,vf2d center,float radius,float degreesCut,Pixel col){ + std::vectordonutUVs{}; + bool first{true}; + std::transform(game->circleCooldownPoints.begin(),game->circleCooldownPoints.end(),std::back_inserter(donutUVs),[&first](const vf2d&point){ + const bool IsFirstPoint{first}; + first=false; + return IsFirstPoint?vf2d{}:vf2d{1,1}; + } + ); + DrawPolygonDecal(GFX[std::string(texture)].Decal(),circleCooldownPoints,donutUVs,std::max(1,int(degreesCut/4)),center,radius,col); +} + void AiL::DrawSquarePie(vf2d center,float radius,float degreesCut,Pixel col){ DrawPolygonDecal(nullptr,squareCircleCooldownPoints,squareCircleCooldownPoints,std::max(1,int(degreesCut/4)),center,radius,col); } @@ -3669,26 +3681,20 @@ void AiL::InitializeGraphics(){ GFX.Reset(); Menu::themes.Reset(); - circleCooldownPoints.push_back({0,0}); - squareCircleCooldownPoints.push_back({0,0}); - for(int i=0;i<=360;i+=4){ - float angle=util::degToRad(float(i))-PI/2; - - #pragma region Donut Circle - const float innerArcRatio{0.8f}; + const float innerArcRatio{0.85f}; - donutCircleCooldownPoints.push_back(vf2d{cos(angle),sin(angle)}); - donutCircleCooldownPoints.push_back(vf2d{cos(angle),sin(angle)}*innerArcRatio); - #pragma endregion - + circleCooldownPoints.emplace_back(vf2d{0,0}); + squareCircleCooldownPoints.emplace_back(vf2d{0,0}); + for(int i=0;i<=360;i+=4){ + float angle=util::degToRad(float(i))-PI/2; #pragma region Cooldown Circles - if(i==0){circleCooldownPoints.push_back(vf2d{cos(angle),sin(angle)});} - circleCooldownPoints.push_back(vf2d{cos(angle),sin(angle)}); + if(i==0){circleCooldownPoints.emplace_back(vf2d{cos(angle),sin(angle)});} + circleCooldownPoints.emplace_back(vf2d{cos(angle),sin(angle)}); vf2d point=vf2d{cos(angle),sin(angle)}*sqrt(2.1f); point.x=std::clamp(point.x,-1.f,1.f); point.y=std::clamp(point.y,-1.f,1.f); - if(i==0){squareCircleCooldownPoints.push_back(point);} - squareCircleCooldownPoints.push_back(point); + if(i==0){squareCircleCooldownPoints.emplace_back(point);} + squareCircleCooldownPoints.emplace_back(point); #pragma endregion } diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index b558bf32..eb0f4e45 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -156,7 +156,6 @@ private: std::vectordropsBeforeLower,dropsAfterLower,dropsBeforeUpper,dropsAfterUpper; std::vectorendZones,upperEndZones; std::vectorcircleCooldownPoints; - std::vectordonutCircleCooldownPoints; std::vectorsquareCircleCooldownPoints; std::mapMAP_TILESETS; vf2d worldShake={}; @@ -316,6 +315,7 @@ public: bool IsReflectiveTile(TilesheetData tileSheet,int tileID); Monster&SpawnMonster(vf2d pos,MonsterData&data,bool upperLevel=false,bool isBossSpawn=false); //Queues a monster for spawning on the next frame. void DrawPie(vf2d center,float radius,float degreesCut,Pixel col); + void DrawPieArc(const std::string_view texture,vf2d center,float radius,float degreesCut,Pixel col); //Draws an arc that has UV coordinates going from (0,0) in the center out to (1,1) void DrawSquarePie(vf2d center,float radius,float degreesCut,Pixel col); void RenderCooldowns(); void InitializeDefaultKeybinds(); diff --git a/Adventures in Lestoria/State_GameRun.cpp b/Adventures in Lestoria/State_GameRun.cpp index 61f3688a..0ad2646f 100644 --- a/Adventures in Lestoria/State_GameRun.cpp +++ b/Adventures in Lestoria/State_GameRun.cpp @@ -90,11 +90,4 @@ void State_GameRun::Draw(AiL*game){ game->RenderWorld(game->GetElapsedTime()); game->RenderHud(); Tutorial::Draw(); - - std::vectorlargeDonut{}; - std::transform(game->donutCircleCooldownPoints.begin(),game->donutCircleCooldownPoints.end(),std::back_inserter(largeDonut),[](const vf2d&point){return vf2d{120,120}+point*64.f;}); - - game->SetDecalStructure(DecalStructure::STRIP); - game->DrawPolygonDecal(nullptr,largeDonut,largeDonut,RED); - game->SetDecalStructure(DecalStructure::FAN); } \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 9cc7a884..eb032fc4 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_PATCH 3 -#define VERSION_BUILD 10836 +#define VERSION_BUILD 10846 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/olcPixelGameEngine.h b/Adventures in Lestoria/olcPixelGameEngine.h index be919e1d..2de79859 100644 --- a/Adventures in Lestoria/olcPixelGameEngine.h +++ b/Adventures in Lestoria/olcPixelGameEngine.h @@ -586,7 +586,7 @@ namespace olc // Pixel Game Engine Advanced Configuration constexpr inline uint8_t nMouseButtons = 5; constexpr inline uint8_t nTabSizeInSpaces = 4; - constexpr inline size_t OLC_MAX_VERTS = 256; + constexpr inline size_t OLC_MAX_VERTS = 128; enum rcode { FAIL = 0, OK = 1, NO_FILE = -1 }; // Thanks to scripticuk and others for updating the key maps // NOTE: The GLUT platform will need updating, open to contributions ;) @@ -3056,6 +3056,7 @@ namespace olc void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector& pos, const std::vector& uv, const olc::Pixel tint) { + if(pos.size()>OLC_MAX_VERTS)throw std::runtime_error("Vertex count exceeds Maximum allowed vertices!"); DecalInstance di; di.decal = decal; di.points = uint32_t(pos.size()); @@ -3077,6 +3078,7 @@ namespace olc void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector& pos, const std::vector& uv, const int startInd, const vf2d&offset, const float scale, const olc::Pixel tint) { + if(pos.size()>OLC_MAX_VERTS)throw std::runtime_error("Vertex count exceeds Maximum allowed vertices!"); DecalInstance di; di.decal = decal; di.points = uint32_t(pos.size()-startInd); @@ -3104,6 +3106,7 @@ namespace olc void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector& pos, const std::vector& uv, const std::vector &tint) { + if(pos.size()>OLC_MAX_VERTS)throw std::runtime_error("Vertex count exceeds Maximum allowed vertices!"); DecalInstance di; di.decal = decal; di.points = uint32_t(pos.size()); @@ -3125,6 +3128,7 @@ namespace olc void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector& pos, const std::vector& uv, const std::vector& colours, const olc::Pixel tint) { + if(pos.size()>OLC_MAX_VERTS)throw std::runtime_error("Vertex count exceeds Maximum allowed vertices!"); std::vector newColours(colours.size(), olc::WHITE); std::transform(colours.begin(), colours.end(), newColours.begin(), [&tint](const olc::Pixel pin) { return pin * tint; }); @@ -3134,6 +3138,7 @@ namespace olc void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector& pos, const std::vector& depth, const std::vector& uv, const olc::Pixel tint) { + if(pos.size()>OLC_MAX_VERTS)throw std::runtime_error("Vertex count exceeds Maximum allowed vertices!"); DecalInstance di; di.decal = decal; di.points = uint32_t(pos.size()); @@ -3155,6 +3160,7 @@ namespace olc void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector& pos, const std::vector& depth, const std::vector& uv, const std::vector& colours, const olc::Pixel tint) { + if(pos.size()>OLC_MAX_VERTS)throw std::runtime_error("Vertex count exceeds Maximum allowed vertices!"); DecalInstance di; di.decal = decal; di.points = uint32_t(pos.size()); diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index a9031eda..84cba21e 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ