Minimap chunk revealing implemented. Release Build 8781.

mac-build
sigonasr2 10 months ago
parent 205a974a7b
commit 6dd032c6f6
  1. 33
      Adventures in Lestoria/Minimap.cpp
  2. 2
      Adventures in Lestoria/Player.cpp
  3. 2
      Adventures in Lestoria/Version.h
  4. BIN
      x64/Release/Adventures in Lestoria.exe

@ -39,6 +39,7 @@ All rights reserved.
#include "AdventuresInLestoria.h"
#include "DEFINES.h"
#include "Unlock.h"
#include "util.h"
INCLUDE_game
@ -126,10 +127,40 @@ 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;y<chunkEndPixelPos.y;y++){
for(int x=pixelPos.x;x<chunkEndPixelPos.x;x++){
if(cover.Sprite()->GetPixel(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<float>(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)<<std::endl);
}
}
void Minimap::Draw(){
game->DrawDecal(vf2d{float(game->ScreenWidth()-minimap.Sprite()->width),0},minimap.Decal());
game->DrawDecal(vf2d{float(game->ScreenWidth()-cover.Sprite()->width),0},cover.Decal());
}

@ -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){

@ -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

Loading…
Cancel
Save