Setup chunk data structure and move black minimap outline rendering to the sprite instead of doing it in the decal rendering. Release Build 8767.
This commit is contained in:
parent
4306f4eab8
commit
c378939994
@ -901,6 +901,7 @@
|
|||||||
<Text Include="assets\config\items\ItemStats.txt" />
|
<Text Include="assets\config\items\ItemStats.txt" />
|
||||||
<Text Include="assets\config\items\Weapons.txt" />
|
<Text Include="assets\config\items\Weapons.txt" />
|
||||||
<Text Include="assets\config\levels.txt" />
|
<Text Include="assets\config\levels.txt" />
|
||||||
|
<Text Include="assets\config\minimap.txt" />
|
||||||
<Text Include="assets\config\Monsters.txt" />
|
<Text Include="assets\config\Monsters.txt" />
|
||||||
<Text Include="assets\config\MonsterStrategies.txt" />
|
<Text Include="assets\config\MonsterStrategies.txt" />
|
||||||
<Text Include="assets\config\NPCs.txt" />
|
<Text Include="assets\config\NPCs.txt" />
|
||||||
|
@ -1175,6 +1175,9 @@
|
|||||||
<Text Include="assets\config\Achievements.txt">
|
<Text Include="assets\config\Achievements.txt">
|
||||||
<Filter>Configurations</Filter>
|
<Filter>Configurations</Filter>
|
||||||
</Text>
|
</Text>
|
||||||
|
<Text Include="assets\config\minimap.txt">
|
||||||
|
<Filter>Configurations</Filter>
|
||||||
|
</Text>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Image Include="assets\heart.ico">
|
<Image Include="assets\heart.ico">
|
||||||
|
@ -236,6 +236,9 @@ AiL::AiL()
|
|||||||
std::string ACHIEVEMENT_CONFIG = CONFIG_PATH + "achievement_config"_S;
|
std::string ACHIEVEMENT_CONFIG = CONFIG_PATH + "achievement_config"_S;
|
||||||
utils::datafile::Read(DATA,ACHIEVEMENT_CONFIG);
|
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;
|
utils::datafile::DEBUG_ACCESS_OPTIONS="debug_access_options"_I;
|
||||||
|
|
||||||
sAppName = "GAME_NAME"_S;
|
sAppName = "GAME_NAME"_S;
|
||||||
|
@ -186,7 +186,6 @@ private:
|
|||||||
float vignetteDisplayTime=0.f;
|
float vignetteDisplayTime=0.f;
|
||||||
bool savingFile=false;
|
bool savingFile=false;
|
||||||
bool prevStageCompleted=false;
|
bool prevStageCompleted=false;
|
||||||
Minimap minimap;
|
|
||||||
|
|
||||||
void ValidateGameStatus();
|
void ValidateGameStatus();
|
||||||
void _PrepareLevel(MapName map,MusicChange changeMusic);
|
void _PrepareLevel(MapName map,MusicChange changeMusic);
|
||||||
@ -334,6 +333,7 @@ public:
|
|||||||
const bool PreviousStageCompleted()const;
|
const bool PreviousStageCompleted()const;
|
||||||
void SetCompletedStageFlag();
|
void SetCompletedStageFlag();
|
||||||
void ResetCompletedStageFlag();
|
void ResetCompletedStageFlag();
|
||||||
|
Minimap minimap;
|
||||||
|
|
||||||
struct TileGroupData{
|
struct TileGroupData{
|
||||||
vi2d tilePos;
|
vi2d tilePos;
|
||||||
|
@ -43,20 +43,30 @@ All rights reserved.
|
|||||||
INCLUDE_game
|
INCLUDE_game
|
||||||
|
|
||||||
void Minimap::Initialize(){
|
void Minimap::Initialize(){
|
||||||
|
loadedChunks.clear();
|
||||||
|
|
||||||
if(minimap.Sprite()==nullptr)minimap.Create(1,1);
|
if(minimap.Sprite()==nullptr)minimap.Create(1,1);
|
||||||
if(cover.Sprite()==nullptr)cover.Create(1,1);
|
if(cover.Sprite()==nullptr)cover.Create(1,1);
|
||||||
|
|
||||||
|
Sprite baseMinimap;
|
||||||
|
|
||||||
#pragma region Cleanup minimap and cover images
|
#pragma region Cleanup minimap and cover images
|
||||||
minimap.Sprite()->Resize(game->GetCurrentMapData().width,game->GetCurrentMapData().height);
|
minimap.Sprite()->Resize(game->GetCurrentMapData().width,game->GetCurrentMapData().height);
|
||||||
cover.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->SetDrawTarget(minimap.Sprite());
|
||||||
game->Clear(WHITE);
|
|
||||||
game->SetPixelMode(Pixel::ALPHA);
|
game->SetPixelMode(Pixel::ALPHA);
|
||||||
|
game->Clear(BLANK);
|
||||||
|
game->SetDrawTarget(&baseMinimap);
|
||||||
|
game->Clear(BLANK);
|
||||||
game->SetDrawTarget(cover.Sprite());
|
game->SetDrawTarget(cover.Sprite());
|
||||||
game->Clear(BLANK);
|
game->Clear(BLANK);
|
||||||
|
game->SetPixelMode(Pixel::NORMAL);
|
||||||
//Will update the minimap decal at the end, since we are about to change it anyways.
|
//Will update the minimap decal at the end, since we are about to change it anyways.
|
||||||
cover.Decal()->Update();
|
cover.Decal()->Update();
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
for(int x=0;x<game->GetCurrentMapData().width;x++){
|
for(int x=0;x<game->GetCurrentMapData().width;x++){
|
||||||
for(int y=0;y<game->GetCurrentMapData().height;y++){
|
for(int y=0;y<game->GetCurrentMapData().height;y++){
|
||||||
bool tileFound=false;
|
bool tileFound=false;
|
||||||
@ -68,9 +78,7 @@ void Minimap::Initialize(){
|
|||||||
if(tileID!=-1){
|
if(tileID!=-1){
|
||||||
tileFound=true;
|
tileFound=true;
|
||||||
if(game->GetTileCollision(game->GetCurrentMapName(),vf2d{float(x),float(y)}*game->GetCurrentMapData().tilewidth)!=game->NO_COLLISION){
|
if(game->GetTileCollision(game->GetCurrentMapName(),vf2d{float(x),float(y)}*game->GetCurrentMapData().tilewidth)!=game->NO_COLLISION){
|
||||||
game->SetPixelMode(Pixel::ALPHA);
|
baseMinimap.SetPixel({x,y},BLANK);
|
||||||
minimap.Sprite()->SetPixel({x,y},BLANK);
|
|
||||||
game->SetPixelMode(Pixel::NORMAL);
|
|
||||||
collision=true;
|
collision=true;
|
||||||
}
|
}
|
||||||
tileCol=game->GetTileColor(game->GetCurrentMapName(),vf2d{float(x),float(y)}*game->GetCurrentMapData().tilewidth);
|
tileCol=game->GetTileColor(game->GetCurrentMapName(),vf2d{float(x),float(y)}*game->GetCurrentMapData().tilewidth);
|
||||||
@ -78,16 +86,35 @@ void Minimap::Initialize(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(tileFound&&!collision){
|
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
|
}else
|
||||||
if(!tileFound){
|
if(!tileFound){
|
||||||
game->SetPixelMode(Pixel::ALPHA);
|
baseMinimap.SetPixel({x,y},BLANK);
|
||||||
minimap.Sprite()->SetPixel({x,y},BLANK);
|
|
||||||
game->SetPixelMode(Pixel::NORMAL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
minimap.Decal()->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,12 +122,14 @@ 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(){
|
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());
|
game->DrawDecal(vf2d{float(game->ScreenWidth()-minimap.Sprite()->width),0},minimap.Decal());
|
||||||
}
|
}
|
@ -42,7 +42,10 @@ public:
|
|||||||
void Initialize();
|
void Initialize();
|
||||||
void Update();
|
void Update();
|
||||||
void Draw();
|
void Draw();
|
||||||
|
|
||||||
|
void UpdateChunk(const vi2d chunkPos);
|
||||||
private:
|
private:
|
||||||
Renderable minimap;
|
Renderable minimap;
|
||||||
Renderable cover;
|
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));
|
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)});
|
ForceSetPos({pos.x,float(game->GetCurrentMapData().playerSpawnLocation.y)});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
game->minimap.UpdateChunk(GetPos()/"Minimap.Chunk Size"_I);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::Spin(float duration,float spinSpd){
|
void Player::Spin(float duration,float spinSpd){
|
||||||
|
@ -39,7 +39,7 @@ All rights reserved.
|
|||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 1
|
#define VERSION_MINOR 1
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 8734
|
#define VERSION_BUILD 8767
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
@ -40,6 +40,9 @@ monsterstrategies_config = MonsterStrategies.txt
|
|||||||
# Interface Theme Config
|
# Interface Theme Config
|
||||||
themes_config = gfx/themes.txt
|
themes_config = gfx/themes.txt
|
||||||
|
|
||||||
|
# Minimap Config
|
||||||
|
minimap_config = minimap.txt
|
||||||
|
|
||||||
# Path to theme image files
|
# Path to theme image files
|
||||||
theme_img_directory = themes/
|
theme_img_directory = themes/
|
||||||
|
|
||||||
|
5
Adventures in Lestoria/assets/config/minimap.txt
Normal file
5
Adventures in Lestoria/assets/config/minimap.txt
Normal file
@ -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 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);
|
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)
|
// 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(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(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(const Pixel&)>colorFunc=[](const Pixel&in){return in;});
|
||||||
// Draws an area of a sprite at location (x,y), where the
|
// Draws an area of a sprite at location (x,y), where the
|
||||||
// selected area is (ox,oy) to (ox+w,oy+h)
|
// 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);
|
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)
|
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); }
|
{ 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)
|
if (sprite == nullptr)
|
||||||
return;
|
return;
|
||||||
@ -3003,7 +3003,7 @@ namespace olc
|
|||||||
for (int32_t j = 0; j < sprite->height; j++, fy += fym)
|
for (int32_t j = 0; j < sprite->height; j++, fy += fym)
|
||||||
for (uint32_t is = 0; is < scale; is++)
|
for (uint32_t is = 0; is < scale; is++)
|
||||||
for (uint32_t js = 0; js < scale; js++)
|
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
|
else
|
||||||
@ -3013,7 +3013,7 @@ namespace olc
|
|||||||
{
|
{
|
||||||
fy = fys;
|
fy = fys;
|
||||||
for (int32_t j = 0; j < sprite->height; j++, fy += fym)
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user