From f48a6a89b2181bbe269c3eaef717679012852240 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 24 Sep 2023 05:23:49 -0500 Subject: [PATCH] Added DrawPie function, fix up invisible foreground tiles (was not rendering). --- Crawler/Crawler.cpp | 13 ++++ Crawler/Crawler.h | 2 + Crawler/Version.h | 2 +- Crawler/assets/Campaigns/1_1_v2.tmx | 2 +- .../maps/Decorations_c1_No_Shadow24x24.tsx | 63 +++++++++++++++++++ Crawler/olcPixelGameEngine.h | 28 +++++++++ 6 files changed, 108 insertions(+), 2 deletions(-) diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 7acbbd61..9f1f9b71 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -75,6 +75,12 @@ Crawler::Crawler() bool Crawler::OnUserCreate(){ InitializeLevels(); + circleCooldownPoints.push_back({0,0}); + for(int i=0;i<=360;i+=4){ + float angle=util::degToRad(i)-PI/2; + circleCooldownPoints.push_back(vf2d{cos(angle),sin(angle)}); + } + player=std::make_unique(); //Initialize Camera. @@ -1052,6 +1058,9 @@ void Crawler::RenderHud(){ DrawShadowStringDecal({0,128},player->GetPos().str()); DrawShadowStringDecal({0,136},"Spd: "+std::to_string(player->GetMoveSpdMult())); } + + + DrawPie({120,120},20,90,BLUE); } void Crawler::AddEffect(std::unique_ptrforeground,std::unique_ptr background){ @@ -1530,4 +1539,8 @@ void Crawler::InitializeLevels(){ void Crawler::SpawnMonster(vf2d pos,MonsterData*data,bool upperLevel){ monstersToBeSpawned.push_back(Monster(pos,*data,upperLevel)); +} + +void Crawler::DrawPie(vf2d center,float radius,float degreesCut,Pixel col){ + DrawPolygonDecal(nullptr,circleCooldownPoints,circleCooldownPoints,int(degreesCut/4),center,radius,col); } \ No newline at end of file diff --git a/Crawler/Crawler.h b/Crawler/Crawler.h index f228849f..3291036c 100644 --- a/Crawler/Crawler.h +++ b/Crawler/Crawler.h @@ -28,6 +28,7 @@ public: private: std::vector>foregroundEffects,backgroundEffects,foregroundEffectsToBeInserted,backgroundEffectsToBeInserted; std::vectortilePreparationList,tileForegroundList; + std::vectorcircleCooldownPoints; std::mapMAP_DATA; std::mapMAP_TILESETS; vf2d worldShake={}; @@ -111,6 +112,7 @@ public: void RenderTile(TileRenderData&tileSheet,Pixel col); bool IsReflectiveTile(TilesheetData tileSheet,int tileID); void SpawnMonster(vf2d pos,MonsterData*data,bool upperLevel=false); //Queues a monster for spawning on the next frame. + void DrawPie(vf2d center,float radius,float degreesCut,Pixel col); struct TileGroupData{ vi2d tilePos; diff --git a/Crawler/Version.h b/Crawler/Version.h index 9e7aef3e..d6b84e93 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 1463 +#define VERSION_BUILD 1484 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/assets/Campaigns/1_1_v2.tmx b/Crawler/assets/Campaigns/1_1_v2.tmx index 9992fba4..46b2ab6b 100644 --- a/Crawler/assets/Campaigns/1_1_v2.tmx +++ b/Crawler/assets/Campaigns/1_1_v2.tmx @@ -803,7 +803,7 @@ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3049,3050,3051,3052,3053,3054,0,0,0,0,3049,3050,3051,3052,3053,3054,0,0,0,3049,3050,3051,3052,3053,3054,0,0,0,3005,3006,3007,3008,0,0,0,0,0,3056,3057,3058,3059,3060,0,0,0,0,3011,3012,3013,3014,0,0,0,0,0,0,0,3061,3062,3063,3064,3065,0,0,3049,3050,3051,3052,3053,3054,0,0,0,0,0,3005,3006,3007,3008,0,0,0,0,0,0,3056,3057,3058,3059,3060,0,0,0,3049,3050,3051,3052,3053,3054,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3005,3006,3007,3008,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3094,3095,3096,3097,3098,3099,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3094,3095,3096,3097,3098,3099,0,0,0,0,3094,3095,3096,3097,3098,3099,0,0,0,3094,3095,3096,3097,3098,3099,0,0,3049,3050,3051,3052,3053,3054,0,0,0,0,3101,3102,3103,3104,3105,0,0,0,0,3056,3057,3058,3059,3060,0,0,0,0,0,0,3106,3107,3108,3109,3110,0,0,3094,3095,3096,3097,3098,3099,3125,0,0,0,3049,3050,3051,3052,3053,3054,0,0,0,0,0,3101,3102,3103,3104,3105,0,0,0,3094,3095,3096,3097,3098,3099,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3049,3050,3051,3052,3053,3054,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3139,3140,3141,3142,3143,3144,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3139,3140,3141,3142,3143,3144,0,0,0,0,3139,3140,3141,3142,3143,3144,0,0,0,3139,3140,3141,3142,3143,3144,0,0,3094,3095,3096,3097,3098,3099,0,0,0,0,3146,3147,3148,3149,3150,0,0,0,0,3101,3102,3103,3104,3105,0,0,0,0,0,0,3151,3152,3153,3154,3155,0,0,3139,3140,3141,3142,3143,3144,3170,3171,0,0,3094,3095,3096,3097,3098,3099,0,0,0,0,0,3146,3147,3148,3149,3150,0,0,0,3139,3140,3141,3142,3143,3144,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3094,3095,3096,3097,3098,3099,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3184,3185,3186,3187,3188,3189,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3184,3185,3186,3187,3188,3189,0,0,0,0,3184,3185,3186,3187,3188,3189,0,0,0,3184,3185,3186,3187,3188,3189,0,0,3139,3140,3141,3142,3143,3144,0,0,0,0,3191,3192,3193,3194,3195,0,0,0,0,3146,3147,3148,3149,3150,0,0,0,0,0,0,3196,3197,3198,3199,3200,0,0,3184,3185,3186,3187,3188,3189,3215,3216,0,0,3139,3140,3141,3142,3143,3144,0,0,0,0,0,3191,3192,3193,3194,3195,0,0,0,3184,3185,3186,3187,3188,3189,0,0,0,0,0,0,0,0,0,0,4589,4541,4541,4541,4541,4541,4597,0,0,3139,3140,3141,3142,3143,3144,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3229,3230,3231,3232,3233,3234,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3184,3185,3186,3187,3188,3189,0,0,0,0,3184,3185,3186,3187,3188,3189,0,0,0,3184,3185,3186,3187,3188,3189,0,0,3139,3140,3141,3142,3143,3144,0,0,0,0,3191,3192,3193,3194,0,0,0,0,0,3146,3147,3148,3149,3150,0,0,0,0,0,0,3196,3197,3198,3199,3200,0,0,3184,3185,3186,3187,3188,3189,3215,3216,0,0,3139,3140,3141,3142,3143,3144,0,0,0,0,0,3191,3192,3193,3194,3195,0,0,0,3184,3185,3186,3187,3188,3189,0,0,0,0,0,0,0,0,0,0,4589,4541,4541,4541,4541,4541,4597,0,0,3139,3140,3141,3142,3143,3144,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3229,3230,3231,3232,3233,3234,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4605,4605,4605,4605,4605,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, diff --git a/Crawler/assets/maps/Decorations_c1_No_Shadow24x24.tsx b/Crawler/assets/maps/Decorations_c1_No_Shadow24x24.tsx index 45e84172..beba3911 100644 --- a/Crawler/assets/maps/Decorations_c1_No_Shadow24x24.tsx +++ b/Crawler/assets/maps/Decorations_c1_No_Shadow24x24.tsx @@ -2,6 +2,9 @@ + + + @@ -38,9 +41,11 @@ + + @@ -55,6 +60,8 @@ + + @@ -144,6 +151,7 @@ + @@ -168,18 +176,28 @@ + + + + + + + + + + @@ -192,15 +210,21 @@ + + + + + + @@ -211,6 +235,9 @@ + + + @@ -221,6 +248,9 @@ + + + @@ -231,11 +261,16 @@ + + + + + @@ -246,11 +281,14 @@ + + + @@ -261,11 +299,13 @@ + + @@ -276,6 +316,8 @@ + + @@ -286,6 +328,7 @@ + @@ -296,8 +339,11 @@ + + + @@ -316,8 +362,10 @@ + + @@ -913,9 +961,12 @@ + + + @@ -1004,16 +1055,20 @@ + + + + @@ -1134,9 +1189,11 @@ + + @@ -1395,6 +1452,7 @@ + @@ -1410,6 +1468,8 @@ + + @@ -1425,6 +1485,8 @@ + + @@ -1440,4 +1502,5 @@ + diff --git a/Crawler/olcPixelGameEngine.h b/Crawler/olcPixelGameEngine.h index 9577b2ca..8fb4b8d7 100644 --- a/Crawler/olcPixelGameEngine.h +++ b/Crawler/olcPixelGameEngine.h @@ -1141,6 +1141,7 @@ namespace olc void GradientFillRectDecal(const olc::vf2d& pos, const olc::vf2d& size, const olc::Pixel colTL, const olc::Pixel colBL, const olc::Pixel colBR, const olc::Pixel colTR); // Draws an arbitrary convex textured polygon using GPU void DrawPolygonDecal(olc::Decal* decal, const std::vector& pos, const std::vector& uv, const olc::Pixel tint = olc::WHITE); + void DrawPolygonDecal(olc::Decal* decal, const std::vector& pos, const std::vector& uv, int startInd, const vf2d&offset, const float scale, const olc::Pixel tint = olc::WHITE); void DrawPolygonDecal(olc::Decal* decal, const std::vector& pos, const std::vector& depth, const std::vector& uv, const olc::Pixel tint = olc::WHITE); void DrawPolygonDecal(olc::Decal* decal, const std::vector& pos, const std::vector& uv, const std::vector& tint); void DrawPolygonDecal(olc::Decal* decal, const std::vector& pos, const std::vector& uv, const std::vector& colours, const olc::Pixel tint); @@ -2969,6 +2970,33 @@ namespace olc vLayers[nTargetLayer].vecDecalInstance.push_back(di); } + 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) + { + DecalInstance di; + di.decal = decal; + di.points = uint32_t(pos.size()-startInd); + di.pos.resize(di.points); + di.uv.resize(di.points); + di.w.resize(di.points); + di.tint.resize(di.points); + if(startInd!=0){ + di.pos[0] = { ((pos[0].x*scale+offset.x) * vInvScreenSize.x) * 2.0f - 1.0f, (((pos[0].y*scale+offset.y) * vInvScreenSize.y) * 2.0f - 1.0f) * -1.0f }; + di.uv[0] = uv[0]; + di.tint[0] = tint; + di.w[0] = 1.0f; + } + for (uint32_t i = 1; i < di.points; i++) + { + di.pos[i] = { ((pos[startInd+i].x*scale+offset.x) * vInvScreenSize.x) * 2.0f - 1.0f, (((pos[startInd+i].y*scale+offset.y) * vInvScreenSize.y) * 2.0f - 1.0f) * -1.0f }; + di.uv[i] = uv[startInd+i]; + di.tint[i] = tint; + di.w[i] = 1.0f; + } + di.mode = nDecalMode; + di.structure = nDecalStructure; + vLayers[nTargetLayer].vecDecalInstance.push_back(di); + } + void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector& pos, const std::vector& uv, const std::vector &tint) { DecalInstance di;