Setup chunk data structure and move black minimap outline rendering to the sprite instead of doing it in the decal rendering. Release Build 8767.

pull/57/head
sigonasr2 10 months ago
parent 4306f4eab8
commit c378939994
  1. 1
      Adventures in Lestoria/Adventures in Lestoria.vcxproj
  2. 3
      Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
  3. 3
      Adventures in Lestoria/AdventuresInLestoria.cpp
  4. 2
      Adventures in Lestoria/AdventuresInLestoria.h
  5. 57
      Adventures in Lestoria/Minimap.cpp
  6. 3
      Adventures in Lestoria/Minimap.h
  7. 2
      Adventures in Lestoria/Player.cpp
  8. 2
      Adventures in Lestoria/Version.h
  9. 3
      Adventures in Lestoria/assets/config/configuration.txt
  10. 5
      Adventures in Lestoria/assets/config/minimap.txt
  11. 14
      Adventures in Lestoria/olcPixelGameEngine.h
  12. BIN
      x64/Release/Adventures in Lestoria.exe

@ -901,6 +901,7 @@
<Text Include="assets\config\items\ItemStats.txt" />
<Text Include="assets\config\items\Weapons.txt" />
<Text Include="assets\config\levels.txt" />
<Text Include="assets\config\minimap.txt" />
<Text Include="assets\config\Monsters.txt" />
<Text Include="assets\config\MonsterStrategies.txt" />
<Text Include="assets\config\NPCs.txt" />

@ -1175,6 +1175,9 @@
<Text Include="assets\config\Achievements.txt">
<Filter>Configurations</Filter>
</Text>
<Text Include="assets\config\minimap.txt">
<Filter>Configurations</Filter>
</Text>
</ItemGroup>
<ItemGroup>
<Image Include="assets\heart.ico">

@ -236,6 +236,9 @@ AiL::AiL()
std::string ACHIEVEMENT_CONFIG = CONFIG_PATH + "achievement_config"_S;
utils::datafile::Read(DATA,ACHIEVEMENT_CONFIG);
std::string MINIMAP_CONFIG = CONFIG_PATH + "minimap_config"_S;
utils::datafile::Read(DATA,MINIMAP_CONFIG);
utils::datafile::DEBUG_ACCESS_OPTIONS="debug_access_options"_I;
sAppName = "GAME_NAME"_S;

@ -186,7 +186,6 @@ private:
float vignetteDisplayTime=0.f;
bool savingFile=false;
bool prevStageCompleted=false;
Minimap minimap;
void ValidateGameStatus();
void _PrepareLevel(MapName map,MusicChange changeMusic);
@ -334,6 +333,7 @@ public:
const bool PreviousStageCompleted()const;
void SetCompletedStageFlag();
void ResetCompletedStageFlag();
Minimap minimap;
struct TileGroupData{
vi2d tilePos;

@ -43,20 +43,30 @@ All rights reserved.
INCLUDE_game
void Minimap::Initialize(){
loadedChunks.clear();
if(minimap.Sprite()==nullptr)minimap.Create(1,1);
if(cover.Sprite()==nullptr)cover.Create(1,1);
Sprite baseMinimap;
#pragma region Cleanup minimap and cover images
minimap.Sprite()->Resize(game->GetCurrentMapData().width,game->GetCurrentMapData().height);
cover.Sprite()->Resize(game->GetCurrentMapData().width,game->GetCurrentMapData().height);
baseMinimap.Resize(game->GetCurrentMapData().width,game->GetCurrentMapData().height);
game->SetDrawTarget(minimap.Sprite());
game->Clear(WHITE);
game->SetPixelMode(Pixel::ALPHA);
game->Clear(BLANK);
game->SetDrawTarget(&baseMinimap);
game->Clear(BLANK);
game->SetDrawTarget(cover.Sprite());
game->Clear(BLANK);
game->SetPixelMode(Pixel::NORMAL);
//Will update the minimap decal at the end, since we are about to change it anyways.
cover.Decal()->Update();
#pragma endregion
for(int x=0;x<game->GetCurrentMapData().width;x++){
for(int y=0;y<game->GetCurrentMapData().height;y++){
bool tileFound=false;
@ -68,9 +78,7 @@ void Minimap::Initialize(){
if(tileID!=-1){
tileFound=true;
if(game->GetTileCollision(game->GetCurrentMapName(),vf2d{float(x),float(y)}*game->GetCurrentMapData().tilewidth)!=game->NO_COLLISION){
game->SetPixelMode(Pixel::ALPHA);
minimap.Sprite()->SetPixel({x,y},BLANK);
game->SetPixelMode(Pixel::NORMAL);
baseMinimap.SetPixel({x,y},BLANK);
collision=true;
}
tileCol=game->GetTileColor(game->GetCurrentMapName(),vf2d{float(x),float(y)}*game->GetCurrentMapData().tilewidth);
@ -78,29 +86,50 @@ void Minimap::Initialize(){
}
}
if(tileFound&&!collision){
minimap.Sprite()->SetPixel({x,y},{uint8_t(std::min(255.f,tileCol.r*1.5f)),uint8_t(std::min(255.f,tileCol.g*1.5f)),uint8_t(std::min(255.f,tileCol.b*1.5f))});
baseMinimap.SetPixel({x,y},{uint8_t(std::min(255.f,tileCol.r*1.5f)),uint8_t(std::min(255.f,tileCol.g*1.5f)),uint8_t(std::min(255.f,tileCol.b*1.5f))});
}else
if(!tileFound){
game->SetPixelMode(Pixel::ALPHA);
minimap.Sprite()->SetPixel({x,y},BLANK);
game->SetPixelMode(Pixel::NORMAL);
baseMinimap.SetPixel({x,y},BLANK);
}
}
}
for(int sy=0;sy<baseMinimap.height;sy++){
for(int sx=0;sx<baseMinimap.width;sx++){
if(baseMinimap.GetPixel(sx,sy).a>0){
for(int y=-1;y<=1;y++){
for(int x=-1;x<=1;x++){
if(x==0&&y==0)continue;
minimap.Sprite()->SetPixel(sx+x,sy+y,BLACK);
}
}
}
}
}
for(int sy=0;sy<baseMinimap.height;sy++){
for(int sx=0;sx<baseMinimap.width;sx++){
if(baseMinimap.GetPixel(sx,sy).a>0){
minimap.Sprite()->SetPixel(sx,sy,baseMinimap.GetPixel(sx,sy));
}
}
}
game->SetDrawTarget(nullptr);
minimap.Decal()->Update();
}
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));
}
}
void Minimap::Draw(){
for(int y=-1;y<=1;y++){
for(int x=-1;x<=1;x++){
if(x==0&&y==0)continue;
else game->DrawDecal(vf2d{float(game->ScreenWidth()-minimap.Sprite()->width),0}+vf2d{float(x),float(y)},minimap.Decal(),{1.f,1.f},BLACK);
}
}
game->DrawDecal(vf2d{float(game->ScreenWidth()-minimap.Sprite()->width),0},minimap.Decal());
}

@ -42,7 +42,10 @@ public:
void Initialize();
void Update();
void Draw();
void UpdateChunk(const vi2d chunkPos);
private:
Renderable minimap;
Renderable cover;
std::unordered_set<std::string>loadedChunks;
};

@ -865,6 +865,8 @@ void Player::Moved(){
ERR(std::format("WARNING! Player Y position is {}...Trying to recover. THIS SHOULD NOT BE HAPPENING!",pos.y));
ForceSetPos({pos.x,float(game->GetCurrentMapData().playerSpawnLocation.y)});
}
game->minimap.UpdateChunk(GetPos()/"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 8734
#define VERSION_BUILD 8767
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -40,6 +40,9 @@ monsterstrategies_config = MonsterStrategies.txt
# Interface Theme Config
themes_config = gfx/themes.txt
# Minimap Config
minimap_config = minimap.txt
# Path to theme image files
theme_img_directory = themes/

@ -0,0 +1,5 @@
Minimap
{
# Chunk size in tiles
Chunk Size = 16
}

@ -1151,8 +1151,8 @@ namespace olc
void FillTexturedTriangle(std::vector<olc::vf2d> vPoints, std::vector<olc::vf2d> vTex, std::vector<olc::Pixel> vColour, olc::Sprite* sprTex);
void FillTexturedPolygon(const std::vector<olc::vf2d>& vPoints, const std::vector<olc::vf2d>& vTex, const std::vector<olc::Pixel>& vColour, olc::Sprite* sprTex, olc::DecalStructure structure = olc::DecalStructure::LIST);
// Draws an entire sprite at location (x,y)
void DrawSprite(int32_t x, int32_t y, Sprite* sprite, uint32_t scale = 1, uint8_t flip = olc::Sprite::NONE, std::function<Pixel(Pixel&)>colorFunc=[](Pixel&in){return in;});
void DrawSprite(const olc::vi2d& pos, Sprite* sprite, uint32_t scale = 1, uint8_t flip = olc::Sprite::NONE, std::function<Pixel(Pixel&)>colorFunc=[](Pixel&in){return in;});
void DrawSprite(int32_t x, int32_t y, Sprite* sprite, uint32_t scale = 1, uint8_t flip = olc::Sprite::NONE, std::function<Pixel(const Pixel&)>colorFunc=[](const Pixel&in){return in;});
void DrawSprite(const olc::vi2d& pos, Sprite* sprite, uint32_t scale = 1, uint8_t flip = olc::Sprite::NONE, std::function<Pixel(const Pixel&)>colorFunc=[](const Pixel&in){return in;});
// Draws an area of a sprite at location (x,y), where the
// selected area is (ox,oy) to (ox+w,oy+h)
void DrawPartialSprite(int32_t x, int32_t y, Sprite* sprite, int32_t ox, int32_t oy, int32_t w, int32_t h, uint32_t scale = 1, uint8_t flip = olc::Sprite::NONE,Pixel colorOverride=WHITE);
@ -2981,10 +2981,10 @@ namespace olc
}
void PixelGameEngine::DrawSprite(const olc::vi2d& pos, Sprite* sprite, uint32_t scale, uint8_t flip, std::function<Pixel(Pixel&)>colorFunc)
{ DrawSprite(pos.x, pos.y, sprite, scale, flip); }
void PixelGameEngine::DrawSprite(const olc::vi2d& pos, Sprite* sprite, uint32_t scale, uint8_t flip, std::function<Pixel(const Pixel&)>colorFunc)
{ DrawSprite(pos.x, pos.y, sprite, scale, flip, colorFunc); }
void PixelGameEngine::DrawSprite(int32_t x, int32_t y, Sprite* sprite, uint32_t scale, uint8_t flip, std::function<Pixel(Pixel&)>colorFunc)
void PixelGameEngine::DrawSprite(int32_t x, int32_t y, Sprite* sprite, uint32_t scale, uint8_t flip, std::function<Pixel(const Pixel&)>colorFunc)
{
if (sprite == nullptr)
return;
@ -3003,7 +3003,7 @@ namespace olc
for (int32_t j = 0; j < sprite->height; j++, fy += fym)
for (uint32_t is = 0; is < scale; is++)
for (uint32_t js = 0; js < scale; js++)
Draw(x + (i * scale) + is, y + (j * scale) + js, sprite->GetPixel(fx, fy));
Draw(x + (i * scale) + is, y + (j * scale) + js, colorFunc(sprite->GetPixel(fx, fy)));
}
}
else
@ -3013,7 +3013,7 @@ namespace olc
{
fy = fys;
for (int32_t j = 0; j < sprite->height; j++, fy += fym)
Draw(x + i, y + j, sprite->GetPixel(fx, fy));
Draw(x + i, y + j, colorFunc(sprite->GetPixel(fx, fy)));
}
}
}

Loading…
Cancel
Save