Added debuff disable indicators.
This commit is contained in:
parent
f365e342a2
commit
6bed39f178
@ -21,3 +21,5 @@ Pixel CONSTANT::ATTACKER_ATTACK_COL={171, 0, 0, 220};
|
|||||||
|
|
||||||
Pixel CONSTANT::HEALER_TARGET_COL={0, 134, 230, 196};
|
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 ATTACKER_ATTACK_COL;
|
||||||
static Pixel HEALER_TARGET_COL;
|
static Pixel HEALER_TARGET_COL;
|
||||||
static Pixel HEALER_ATTACK_COL;
|
static Pixel HEALER_ATTACK_COL;
|
||||||
|
|
||||||
|
static float DEBUFFICON_LIFETIME;
|
||||||
};
|
};
|
11
olcCodeJam2023Entry/DebuffIcon.cpp
Normal file
11
olcCodeJam2023Entry/DebuffIcon.cpp
Normal file
@ -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)});
|
||||||
|
}
|
13
olcCodeJam2023Entry/DebuffIcon.h
Normal file
13
olcCodeJam2023Entry/DebuffIcon.h
Normal file
@ -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,
|
SPD,
|
||||||
TARGETING_LINE,
|
TARGETING_LINE,
|
||||||
ATTACKING_LINE,
|
ATTACKING_LINE,
|
||||||
|
RLD_ICON,
|
||||||
|
PRC_ICON,
|
||||||
|
RNG_ICON,
|
||||||
|
SPD_ICON,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "olcUTIL_Geometry2D.h"
|
#include "olcUTIL_Geometry2D.h"
|
||||||
#include "TileManager.h"
|
#include "TileManager.h"
|
||||||
#include "util.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)
|
BasicUnit::BasicUnit(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable)
|
||||||
:Unit(pge,{
|
: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;
|
if(reloadTimer>0)return;
|
||||||
std::weak_ptr<Unit>finalTarget;
|
std::weak_ptr<Unit>finalTarget;
|
||||||
if(!unit.expired()){
|
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(!finalTarget.expired()){
|
||||||
if(InRange(finalTarget.lock())){
|
if(InRange(finalTarget.lock())){
|
||||||
appliedTarget=finalTarget;
|
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.
|
_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 "Sound.h"
|
||||||
#include "olcPGEX_AudioSource.h"
|
#include "olcPGEX_AudioSource.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "DebuffIcon.h"
|
||||||
|
|
||||||
struct Marker{
|
struct Marker{
|
||||||
size_t index;
|
size_t index;
|
||||||
@ -52,7 +53,7 @@ public:
|
|||||||
void SetTargetUnit(std::weak_ptr<Unit>target);
|
void SetTargetUnit(std::weak_ptr<Unit>target);
|
||||||
void SetTargetLocation(vf2d targetLoc);
|
void SetTargetLocation(vf2d targetLoc);
|
||||||
void SetPos(vf2d newPos);
|
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 InFogOfWar();
|
||||||
bool GhostInFogOfWar();
|
bool GhostInFogOfWar();
|
||||||
void HideGhost();
|
void HideGhost();
|
||||||
|
@ -42,6 +42,10 @@ void VirusAttack::InitializeImages(){
|
|||||||
LoadImage(SPD,"assets/spd.png");
|
LoadImage(SPD,"assets/spd.png");
|
||||||
LoadImage(TARGETING_LINE,"assets/targetLine.png");
|
LoadImage(TARGETING_LINE,"assets/targetLine.png");
|
||||||
LoadImage(ATTACKING_LINE,"assets/attackLine.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(){
|
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);
|
u->_Update(this,SOUNDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,6 +402,13 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
|
|||||||
u->DrawUnitDamageStats(this,game,IMAGES);
|
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){
|
for(auto&u:units){
|
||||||
u->DrawHud(game,IMAGES);
|
u->DrawHud(game,IMAGES);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "olcPGEX_AudioListener.h"
|
#include "olcPGEX_AudioListener.h"
|
||||||
#include "olcPGEX_AudioSource.h"
|
#include "olcPGEX_AudioSource.h"
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
|
#include "DebuffIcon.h"
|
||||||
|
|
||||||
struct Letter{
|
struct Letter{
|
||||||
vf2d pos;
|
vf2d pos;
|
||||||
@ -32,6 +33,7 @@ private:
|
|||||||
std::vector<std::shared_ptr<Unit>>units;
|
std::vector<std::shared_ptr<Unit>>units;
|
||||||
std::vector<std::unique_ptr<CollectionPoint>>collectionPoints;
|
std::vector<std::unique_ptr<CollectionPoint>>collectionPoints;
|
||||||
std::vector<std::unique_ptr<DeathAnimation>>deathAnimations;
|
std::vector<std::unique_ptr<DeathAnimation>>deathAnimations;
|
||||||
|
std::vector<DebuffIcon>debuffIcons;
|
||||||
|
|
||||||
std::map<Image,std::unique_ptr<Renderable>>IMAGES;
|
std::map<Image,std::unique_ptr<Renderable>>IMAGES;
|
||||||
std::map<Sound,std::unique_ptr<Audio>>SOUNDS;
|
std::map<Sound,std::unique_ptr<Audio>>SOUNDS;
|
||||||
|
@ -141,6 +141,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Constant.h" />
|
<ClInclude Include="Constant.h" />
|
||||||
<ClInclude Include="DeathAnimation.h" />
|
<ClInclude Include="DeathAnimation.h" />
|
||||||
|
<ClInclude Include="DebuffIcon.h" />
|
||||||
<ClInclude Include="Image.h" />
|
<ClInclude Include="Image.h" />
|
||||||
<ClInclude Include="olcPGEX_AudioListener.h" />
|
<ClInclude Include="olcPGEX_AudioListener.h" />
|
||||||
<ClInclude Include="olcPGEX_AudioSource.h" />
|
<ClInclude Include="olcPGEX_AudioSource.h" />
|
||||||
@ -163,6 +164,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Constant.cpp" />
|
<ClCompile Include="Constant.cpp" />
|
||||||
<ClCompile Include="DeathAnimations.cpp" />
|
<ClCompile Include="DeathAnimations.cpp" />
|
||||||
|
<ClCompile Include="DebuffIcon.cpp" />
|
||||||
<ClCompile Include="TileManager.cpp" />
|
<ClCompile Include="TileManager.cpp" />
|
||||||
<ClCompile Include="Unit.cpp" />
|
<ClCompile Include="Unit.cpp" />
|
||||||
<ClCompile Include="util.cpp" />
|
<ClCompile Include="util.cpp" />
|
||||||
|
@ -78,6 +78,9 @@
|
|||||||
<ClInclude Include="Sound.h">
|
<ClInclude Include="Sound.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="DebuffIcon.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="VirusAttack.cpp">
|
<ClCompile Include="VirusAttack.cpp">
|
||||||
@ -98,6 +101,9 @@
|
|||||||
<ClCompile Include="DeathAnimations.cpp">
|
<ClCompile Include="DeathAnimations.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="DebuffIcon.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="olcCodeJam2023Entry.rc">
|
<ResourceCompile Include="olcCodeJam2023Entry.rc">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user