diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 3dc8b302..d6af078e 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -272,19 +272,19 @@ bool AiL::OnUserCreate(){ ItemInfo::InitializeItems(); - player=std::make_unique(); + InitializeGraphics(); + InitializeClasses(); - healthCounter.Initialize(&player->hp,"Interface.HUD Health Tick Rate"_F,"Interface.HUD Health Display Color"_Pixel,"Interface.HUD Heal Damage Color"_Pixel,"Interface.HUD Take Damage Color"_Pixel,"Interface.HUD Health Change Time"_F); - manaCounter.Initialize(&player->mana,"Interface.HUD Mana Tick Rate"_F,"Interface.HUD Mana Display Color"_Pixel,"Interface.HUD Restore Mana Color"_Pixel,"Interface.HUD Reduce Mana Color"_Pixel,"Interface.HUD Mana Change Time"_F); + sig::Animation::InitializeAnimations(); + + player=std::make_unique(); InitializePlayerLevelCap(); - InitializeGraphics(); - InitializeClasses(); + healthCounter.Initialize(&player->hp,"Interface.HUD Health Tick Rate"_F,"Interface.HUD Health Display Color"_Pixel,"Interface.HUD Heal Damage Color"_Pixel,"Interface.HUD Take Damage Color"_Pixel,"Interface.HUD Health Change Time"_F); + manaCounter.Initialize(&player->mana,"Interface.HUD Mana Tick Rate"_F,"Interface.HUD Mana Display Color"_Pixel,"Interface.HUD Restore Mana Color"_Pixel,"Interface.HUD Reduce Mana Color"_Pixel,"Interface.HUD Mana Change Time"_F); Monster::InitializeStrategies(); - //Animations - sig::Animation::InitializeAnimations(); MonsterData::InitializeMonsterData(); MonsterData::InitializeNPCData(); @@ -353,6 +353,7 @@ bool AiL::OnUserCreate(){ SetupDiscord(); #endif + player->InitializeMinimapImage(); minimap.Initialize(); gameInitialized=true; @@ -2700,6 +2701,7 @@ void AiL::ChangePlayerClass(Class cl){ camera.SetTarget(player->GetPos()); Component(CHARACTER_MENU,"Level Class Display")->SetLabel(std::format("Lv{} {}",game->GetPlayer()->Level(),game->GetPlayer()->GetClassName())); Player::moneyListeners=moneyListeners; + GetPlayer()->InitializeMinimapImage(); } void AiL::InitializeClasses(){ diff --git a/Adventures in Lestoria/Minimap.cpp b/Adventures in Lestoria/Minimap.cpp index a2eaedb7..7db80998 100644 --- a/Adventures in Lestoria/Minimap.cpp +++ b/Adventures in Lestoria/Minimap.cpp @@ -42,6 +42,7 @@ All rights reserved. #include "util.h" INCLUDE_game +INCLUDE_GFX void Minimap::Initialize(){ std::vectorenlargedCircle; @@ -176,7 +177,10 @@ void Minimap::UpdateChunk(const MapName map,const vi2d chunkPos){ } void Minimap::Draw(){ - if(!game->InBossEncounter())mapCircleHud.DrawRotatedDecal(vf2d{float("Minimap.Minimap HUD Size"_I),float("Minimap.Minimap HUD Size"_I)}/2,cover.Decal(),0.f,game->GetPlayer()->GetPos()/game->GetCurrentMapData().tilewidth,vf2d{0.5f,0.5f}); + const vf2d minimapPos=vf2d{float("Minimap.Minimap HUD Size"_I),float("Minimap.Minimap HUD Size"_I)}/2; + if(!game->InBossEncounter())mapCircleHud.DrawRotatedDecal(minimapPos,cover.Decal(),0.f,game->GetPlayer()->GetPos()/game->GetCurrentMapData().tilewidth,vf2d{0.5f,0.5f}); + game->DrawRotatedDecal(mapCircleHud.GetOffset()+minimapPos,GFX["skill_overlay_icon.png"].Decal(),0.f,GFX["skill_overlay_icon.png"].Sprite()->Size()/2,vf2d{float("Minimap.Minimap HUD Size"_I),float("Minimap.Minimap HUD Size"_I)}/24.f*1.05f); + game->DrawRotatedDecal(mapCircleHud.GetOffset()+minimapPos,game->GetPlayer()->GetMinimapImage().Decal(),0.f,vi2d{"Player.Minimap Image Size"_i[0],"Player.Minimap Image Size"_i[1]}/2,{0.5f,0.5f}); } void Minimap::EraseChunkData(){ diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index 9572c8b8..8855b5e4 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -111,6 +111,33 @@ void Player::Initialize(){ cooldownSoundInstance=Audio::Engine().LoadSound("spell_cast.ogg"_SFX); } +void Player::InitializeMinimapImage(){ + #pragma region Setup Minimap Image + minimapImg.Create("Player.Minimap Image Size"_i[0],"Player.Minimap Image Size"_i[1]); + game->SetDrawTarget(minimapImg.Sprite()); + game->SetPixelMode(Pixel::Mode::ALPHA); + game->Clear(BLANK); + for(int y=0;y<"Player.Minimap Image Size"_i[1];y++){ + for(int x=0;x<"Player.Minimap Image Size"_i[0];x++){ + const int radius="Player.Minimap Image Size"_i[0]/2; + const vi2d center=vi2d{"Player.Minimap Image Offset"_i[0],"Player.Minimap Image Offset"_i[1]}; + vi2d imgOffset=vi2d{-"Player.Minimap Image Size"_i[0]/2,-"Player.Minimap Image Size"_i[1]/2}+vi2d{"Player.Minimap Image Offset"_i[0],"Player.Minimap Image Offset"_i[1]}; + float dist=geom2d::line{imgOffset+vi2d{x,y},center}.length(); + if(dist>radius)continue; + std::string className=GetWalkSAnimation(); + Animate2D::FrameSequence sequence=ANIMATION_DATA.at(className); + Animate2D::Frame frame=sequence.GetFrame(0.f); + const Renderable*temp=frame.GetSourceImage(); + Pixel col=temp->Sprite()->GetPixel(imgOffset+vi2d{x,y}); + minimapImg.Sprite()->SetPixel({x,y},col); + } + } + game->SetDrawTarget(nullptr); + game->SetPixelMode(Pixel::Mode::NORMAL); + minimapImg.Decal()->Update(); + #pragma endregion +} + void Player::ForceSetPos(vf2d pos){ this->pos=pos; Moved(); @@ -866,7 +893,7 @@ void Player::Moved(){ ForceSetPos({pos.x,float(game->GetCurrentMapData().playerSpawnLocation.y)}); } - game->minimap.UpdateChunk(game->GetCurrentMapName(),GetPos()/24/"Minimap.Chunk Size"_I); + game->minimap.UpdateChunk(game->GetCurrentMapName(),GetPos()/game->GetCurrentMapData().tilewidth/"Minimap.Chunk Size"_I); } void Player::Spin(float duration,float spinSpd){ @@ -1504,4 +1531,8 @@ const float Player::GetAtkGrowthRate()const{ const float Player::GetIframeTime()const{ return iframe_time; +} + +const Renderable&Player::GetMinimapImage()const{ + return minimapImg; } \ No newline at end of file diff --git a/Adventures in Lestoria/Player.h b/Adventures in Lestoria/Player.h index 734fc402..1dbc928c 100644 --- a/Adventures in Lestoria/Player.h +++ b/Adventures in Lestoria/Player.h @@ -252,6 +252,7 @@ public: const float GetHealthGrowthRate()const; const float GetAtkGrowthRate()const; const float GetIframeTime()const; + const Renderable&GetMinimapImage()const; private: int hp="Warrior.BaseHealth"_I; int mana="Player.BaseMana"_I; @@ -313,9 +314,11 @@ private: //Typical usage is playerInvoked is true on first call, and playerInvoked is false on all subsequent chained calls. bool _SetY(float y,const bool playerInvoked=true); const bool UsingAutoAim()const; + void InitializeMinimapImage(); bool lowHealthSoundPlayed=false; float lowHealthSoundPlayedTimer=0.f; float rangerShootAnimationTimer=0.f; + Renderable minimapImg; //An image of the character represented on a minimap. Should be 12x12 and generally be a circle. protected: const float ATTACK_COOLDOWN="Warrior.Auto Attack.Cooldown"_F; const float MAGIC_ATTACK_COOLDOWN="Wizard.Auto Attack.Cooldown"_F; diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 077ebca4..cf9e0f83 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 8825 +#define VERSION_BUILD 8851 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/config/Player.txt b/Adventures in Lestoria/assets/config/Player.txt index 2f8acdae..db14f99b 100644 --- a/Adventures in Lestoria/assets/config/Player.txt +++ b/Adventures in Lestoria/assets/config/Player.txt @@ -6,6 +6,12 @@ Player # Game Map Starting Location Starting Location = Story I + # Class Minimap Image offset + Minimap Image Offset = 12,11 + + # Class Minimap Image Size (Total Width and Height, starting from the center going out) Ex: 12 means 6 in both directions. + Minimap Image Size = 12,12 + # Starting base crit rate. Crit Rate = 0% diff --git a/Adventures in Lestoria/assets/ranger-map.png b/Adventures in Lestoria/assets/ranger-map.png new file mode 100644 index 00000000..d0e75566 Binary files /dev/null and b/Adventures in Lestoria/assets/ranger-map.png differ diff --git a/Adventures in Lestoria/assets/warrior-map.png b/Adventures in Lestoria/assets/warrior-map.png new file mode 100644 index 00000000..41f5f262 Binary files /dev/null and b/Adventures in Lestoria/assets/warrior-map.png differ diff --git a/Adventures in Lestoria/assets/wizard-map.png b/Adventures in Lestoria/assets/wizard-map.png new file mode 100644 index 00000000..dcd2c70c Binary files /dev/null and b/Adventures in Lestoria/assets/wizard-map.png differ diff --git a/Adventures in Lestoria/olcPGEX_ViewPort.h b/Adventures in Lestoria/olcPGEX_ViewPort.h index c2c43205..c5781917 100644 --- a/Adventures in Lestoria/olcPGEX_ViewPort.h +++ b/Adventures in Lestoria/olcPGEX_ViewPort.h @@ -23,6 +23,7 @@ namespace olc { void clear(); void drawEdges(); void setOffset(vf2d offset); + const vf2d&GetOffset(); static ViewPort rectViewPort(vf2d topLeft, vf2d size, @@ -178,6 +179,10 @@ void olc::ViewPort::setOffset(vf2d offset) { this->offset = offset; } +const vf2d&olc::ViewPort::GetOffset() { + return offset; +} + olc::ViewPort olc::ViewPort::rectViewPort(vf2d topLeft, vf2d size, olc::vf2d offset) { olc::ViewPort newPort={{ diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 175c51a8..dc94a93b 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ