Added visuals for fog of war

CorrectiveAction
sigonasr2 1 year ago
parent 27c5b5d948
commit 0e5689ad0c
  1. 22
      olcCodeJam2023Entry/VirusAttack.cpp
  2. 1
      olcCodeJam2023Entry/VirusAttack.h
  3. 8
      olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj

@ -179,6 +179,12 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
HandlePanAndZoom(fElapsedTime);
HandleMinimapClick();
for(auto&tile:visibleTiles){
tile.second-=fElapsedTime;
}
std::erase_if(visibleTiles,[](std::pair<vf2d,float> key){return key.second<=0;});
for(auto&u:units){
Unit*closestUnit=nullptr;
float closestDist=999999;
@ -186,6 +192,13 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
IdentifyClosestTarget(closestUnit,closestDist,u,u2);
CollisionChecking(u,u2);
}
if(u->IsFriendly()){
for(int y=-1;y<2;y++){
for(int x=-1;x<2;x++){
visibleTiles[u->GetPos()/24/4+vi2d(x,y)]=5;
}
}
}
u->AttemptAttack(closestUnit);
u->Update(fElapsedTime);
}
@ -199,6 +212,15 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
}
DrawSelectionRectangle();
for(int y=game.GetTopLeftTile().y/96-1;y<=game.GetBottomRightTile().y/96+1;y++){
for(int x=game.GetTopLeftTile().x/96-1;x<=game.GetBottomRightTile().x/96+1;x++){
if(visibleTiles.count(vi2d{x,y})==0){
if(x>=0&&y>=0&&x<=CONSTANT::WORLD_SIZE.x*CONSTANT::TILE_SIZE.x&&y<=CONSTANT::WORLD_SIZE.y*CONSTANT::TILE_SIZE.y){
game.FillRectDecal(vf2d{float(x),float(y)}*96,{96,96},{0,0,0,128});
}
}
}
}
DrawMinimap();

@ -7,6 +7,7 @@ class VirusAttack : public olc::PixelGameEngine
{
private:
std::vector<std::shared_ptr<Unit>>units;
std::map<vi2d,float>visibleTiles;
Renderable TILE,MINIMAP_HUD,OUTLINE,MINIMAP_OUTLINE;

@ -76,7 +76,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -91,7 +91,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -106,7 +106,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -121,7 +121,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

Loading…
Cancel
Save