diff --git a/Adventures in Lestoria/Minimap.cpp b/Adventures in Lestoria/Minimap.cpp index d5346f67..68e824d6 100644 --- a/Adventures in Lestoria/Minimap.cpp +++ b/Adventures in Lestoria/Minimap.cpp @@ -39,6 +39,7 @@ All rights reserved. #include "AdventuresInLestoria.h" #include "DEFINES.h" #include "Unlock.h" +#include "util.h" INCLUDE_game @@ -125,11 +126,41 @@ void Minimap::Update(){ void Minimap::UpdateChunk(const vi2d chunkPos){ if(!loadedChunks.count(std::format("{}_{}",chunkPos.x,chunkPos.y))){ loadedChunks.insert(std::format("{}_{}",chunkPos.x,chunkPos.y)); + + vi2d centerChunkPos=chunkPos*"Minimap.Chunk Size"_I; + + vi2d pixelPos=centerChunkPos-"Minimap.Chunk Size"_I*2; + vi2d chunkEndPixelPos=centerChunkPos+"Minimap.Chunk Size"_I*4; + + //We start twice the distance we are supposed to outwards. + for(int y=pixelPos.y;yGetPixel(x,y).a==255||minimap.Sprite()->GetPixel(x,y).a==0)continue; //Already revealed or invisible anyways. + + vi2d chunk=vi2d{x,y}/"Minimap.Chunk Size"_I; + if(chunk==chunkPos){ + cover.Sprite()->SetPixel(x,y,minimap.Sprite()->GetPixel(x,y)); + }else{ + const vi2d chunkOffset={"Minimap.Chunk Size"_I/2,"Minimap.Chunk Size"_I/2}; + + const float distance=geom2d::line(centerChunkPos+chunkOffset,vf2d{float(x),float(y)}).length(); + const int alpha=std::clamp(util::lerp(255,0,(distance-"Minimap.Chunk Size"_I)/"Minimap.Chunk Size"_I),0.f,255.f); + + if(cover.Sprite()->GetPixel(x,y).a>alpha)continue; //The distance was uncovered by another closer chunk, don't need to reveal it here. + + Pixel sourceCol=minimap.Sprite()->GetPixel(x,y); + sourceCol.a=alpha; + cover.Sprite()->SetPixel(x,y,sourceCol); + } + } + } + cover.Decal()->Update(); + LOG(std::format("Chunk {}_{} Revealed",chunkPos.x,chunkPos.y)<DrawDecal(vf2d{float(game->ScreenWidth()-minimap.Sprite()->width),0},minimap.Decal()); + game->DrawDecal(vf2d{float(game->ScreenWidth()-cover.Sprite()->width),0},cover.Decal()); } \ No newline at end of file diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index d0e4e20c..deb2d954 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -866,7 +866,7 @@ void Player::Moved(){ ForceSetPos({pos.x,float(game->GetCurrentMapData().playerSpawnLocation.y)}); } - game->minimap.UpdateChunk(GetPos()/"Minimap.Chunk Size"_I); + game->minimap.UpdateChunk(GetPos()/24/"Minimap.Chunk Size"_I); } void Player::Spin(float duration,float spinSpd){ diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 70da66c3..aacd07de 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 1 #define VERSION_PATCH 0 -#define VERSION_BUILD 8767 +#define VERSION_BUILD 8781 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 5d8a2151..cd9c5ba9 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ