Added debuff disable indicators.

CorrectiveAction
sigonasr2 1 year ago
parent f365e342a2
commit 6bed39f178
  1. 4
      olcCodeJam2023Entry/Constant.cpp
  2. 2
      olcCodeJam2023Entry/Constant.h
  3. 11
      olcCodeJam2023Entry/DebuffIcon.cpp
  4. 13
      olcCodeJam2023Entry/DebuffIcon.h
  5. 4
      olcCodeJam2023Entry/Image.h
  6. 19
      olcCodeJam2023Entry/Unit.cpp
  7. 3
      olcCodeJam2023Entry/Unit.h
  8. 13
      olcCodeJam2023Entry/VirusAttack.cpp
  9. 2
      olcCodeJam2023Entry/VirusAttack.h
  10. 2
      olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj
  11. 6
      olcCodeJam2023Entry/olcCodeJam2023Entry.vcxproj.filters

@ -20,4 +20,6 @@ Pixel CONSTANT::ATTACKER_TARGET_COL={196, 101, 0, 196};
Pixel CONSTANT::ATTACKER_ATTACK_COL={171, 0, 0, 220};
Pixel CONSTANT::HEALER_TARGET_COL={0, 134, 230, 196};
Pixel CONSTANT::HEALER_ATTACK_COL={91, 222, 104, 220};
Pixel CONSTANT::HEALER_ATTACK_COL={91, 222, 104, 220};
float CONSTANT::DEBUFFICON_LIFETIME=0.8;

@ -25,4 +25,6 @@ public:
static Pixel ATTACKER_ATTACK_COL;
static Pixel HEALER_TARGET_COL;
static Pixel HEALER_ATTACK_COL;
static float DEBUFFICON_LIFETIME;
};

@ -0,0 +1,11 @@
#include "DebuffIcon.h"
void DebuffIcon::Update(float fElapsedTime){
pos.y-=6*fElapsedTime;
lifetime-=fElapsedTime;
}
void DebuffIcon::Draw(TileTransformedView&game){
game.DrawRotatedDecal(pos,icon->Decal(),0,icon->Sprite()->Size()/2,{1,1},{255,255,255,uint8_t((lifetime/CONSTANT::DEBUFFICON_LIFETIME)*255)});
game.DrawRotatedDecal(pos+vf2d{4,-4},redXIcon->Decal(),0,icon->Sprite()->Size()/2,{1,1},{255,255,255,uint8_t((lifetime/CONSTANT::DEBUFFICON_LIFETIME)*255)});
}

@ -0,0 +1,13 @@
#pragma once
#include "olcPixelGameEngine.h"
#include "olcPGEX_TransformedView.h"
#include "Constant.h"
struct DebuffIcon{
Renderable*icon;
Renderable*redXIcon;
vf2d pos;
float lifetime=CONSTANT::DEBUFFICON_LIFETIME;
void Update(float fElapsedTime);
void Draw(TileTransformedView&game);
};

@ -26,5 +26,9 @@ enum Image{
SPD,
TARGETING_LINE,
ATTACKING_LINE,
RLD_ICON,
PRC_ICON,
RNG_ICON,
SPD_ICON,
};

@ -2,6 +2,7 @@
#include "olcUTIL_Geometry2D.h"
#include "TileManager.h"
#include "util.h"
#include "DebuffIcon.h"
BasicUnit::BasicUnit(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable)
:Unit(pge,{
@ -532,7 +533,7 @@ void Unit::SetPos(vf2d newPos){
}
}
void Unit::AttemptAttack(std::weak_ptr<Unit>attacker,std::weak_ptr<Unit>unit,std::vector<std::shared_ptr<Unit>>&otherUnits){
void Unit::AttemptAttack(std::weak_ptr<Unit>attacker,std::weak_ptr<Unit>unit,std::vector<std::shared_ptr<Unit>>&otherUnits,std::vector<DebuffIcon>&debuffIcons,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){
if(reloadTimer>0)return;
std::weak_ptr<Unit>finalTarget;
if(!unit.expired()){
@ -547,7 +548,23 @@ void Unit::AttemptAttack(std::weak_ptr<Unit>attacker,std::weak_ptr<Unit>unit,std
if(!finalTarget.expired()){
if(InRange(finalTarget.lock())){
appliedTarget=finalTarget;
bool hadAtkSpd=finalTarget.lock()->GetAtkSpd()>0;
bool hadMoveSpd=finalTarget.lock()->GetMoveSpd()>0;
bool hadRange=finalTarget.lock()->GetRange()>0;
bool hadProcedure=finalTarget.lock()->GetProcedure()>0;
_Attack(attacker,finalTarget,otherUnits); //Call the parent function first, followed by the child.
if(hadAtkSpd&&finalTarget.lock()->GetAtkSpd()==0){
debuffIcons.emplace_back(IMAGES[RLD_ICON].get(),IMAGES[RED_X].get(),finalTarget.lock()->GetPos()-vf2d{util::random(12)-6,4});
}
if(hadMoveSpd&&finalTarget.lock()->GetMoveSpd()==0){
debuffIcons.emplace_back(IMAGES[SPD_ICON].get(),IMAGES[RED_X].get(),finalTarget.lock()->GetPos()-vf2d{util::random(12)-6,4});
}
if(hadRange&&finalTarget.lock()->GetRange()==0){
debuffIcons.emplace_back(IMAGES[RNG_ICON].get(),IMAGES[RED_X].get(),finalTarget.lock()->GetPos()-vf2d{util::random(12)-6,4});
}
if(hadProcedure&&finalTarget.lock()->GetProcedure()==0){
debuffIcons.emplace_back(IMAGES[PRC_ICON].get(),IMAGES[RED_X].get(),finalTarget.lock()->GetPos()-vf2d{util::random(12)-6,4});
}
}
}
}

@ -7,6 +7,7 @@
#include "Sound.h"
#include "olcPGEX_AudioSource.h"
#include "util.h"
#include "DebuffIcon.h"
struct Marker{
size_t index;
@ -52,7 +53,7 @@ public:
void SetTargetUnit(std::weak_ptr<Unit>target);
void SetTargetLocation(vf2d targetLoc);
void SetPos(vf2d newPos);
void AttemptAttack(std::weak_ptr<Unit>attacker,std::weak_ptr<Unit>unit,std::vector<std::shared_ptr<Unit>>&otherUnits);
void AttemptAttack(std::weak_ptr<Unit>attacker,std::weak_ptr<Unit>unit,std::vector<std::shared_ptr<Unit>>&otherUnits,std::vector<DebuffIcon>&debuffIcons,std::map<Image,std::unique_ptr<Renderable>>&IMAGES);
bool InFogOfWar();
bool GhostInFogOfWar();
void HideGhost();

@ -42,6 +42,10 @@ void VirusAttack::InitializeImages(){
LoadImage(SPD,"assets/spd.png");
LoadImage(TARGETING_LINE,"assets/targetLine.png");
LoadImage(ATTACKING_LINE,"assets/attackLine.png");
LoadImage(RLD_ICON,"assets/rld_icon.png");
LoadImage(PRC_ICON,"assets/prc_icon.png");
LoadImage(RNG_ICON,"assets/rng_icon.png");
LoadImage(SPD_ICON,"assets/spd_icon.png");
}
bool VirusAttack::OnUserCreate(){
@ -358,7 +362,7 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
}
}
}
u->AttemptAttack(u,closestUnit,units);
u->AttemptAttack(u,closestUnit,units,debuffIcons,IMAGES);
u->_Update(this,SOUNDS);
}
@ -398,6 +402,13 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
u->DrawUnitDamageStats(this,game,IMAGES);
}
for(DebuffIcon&icon:debuffIcons){
icon.Update(fElapsedTime);
icon.Draw(game);
}
std::erase_if(debuffIcons,[](DebuffIcon&icon){return icon.lifetime<=0;});
for(auto&u:units){
u->DrawHud(game,IMAGES);
}

@ -8,6 +8,7 @@
#include "olcPGEX_AudioListener.h"
#include "olcPGEX_AudioSource.h"
#include "Sound.h"
#include "DebuffIcon.h"
struct Letter{
vf2d pos;
@ -32,6 +33,7 @@ private:
std::vector<std::shared_ptr<Unit>>units;
std::vector<std::unique_ptr<CollectionPoint>>collectionPoints;
std::vector<std::unique_ptr<DeathAnimation>>deathAnimations;
std::vector<DebuffIcon>debuffIcons;
std::map<Image,std::unique_ptr<Renderable>>IMAGES;
std::map<Sound,std::unique_ptr<Audio>>SOUNDS;

@ -141,6 +141,7 @@
<ItemGroup>
<ClInclude Include="Constant.h" />
<ClInclude Include="DeathAnimation.h" />
<ClInclude Include="DebuffIcon.h" />
<ClInclude Include="Image.h" />
<ClInclude Include="olcPGEX_AudioListener.h" />
<ClInclude Include="olcPGEX_AudioSource.h" />
@ -163,6 +164,7 @@
<ItemGroup>
<ClCompile Include="Constant.cpp" />
<ClCompile Include="DeathAnimations.cpp" />
<ClCompile Include="DebuffIcon.cpp" />
<ClCompile Include="TileManager.cpp" />
<ClCompile Include="Unit.cpp" />
<ClCompile Include="util.cpp" />

@ -78,6 +78,9 @@
<ClInclude Include="Sound.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DebuffIcon.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="VirusAttack.cpp">
@ -98,6 +101,9 @@
<ClCompile Include="DeathAnimations.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DebuffIcon.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="olcCodeJam2023Entry.rc">

Loading…
Cancel
Save