From 18e8a02579c59bfcfd176eccc1d4691371c7e67c Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Tue, 29 Aug 2023 05:18:40 -0500 Subject: [PATCH] Added target line indicators. --- olcCodeJam2023Entry/Constant.cpp | 8 +- olcCodeJam2023Entry/Constant.h | 5 + olcCodeJam2023Entry/Image.h | 2 + olcCodeJam2023Entry/Info.txt | 11 +- olcCodeJam2023Entry/Sound.h | 5 + olcCodeJam2023Entry/Unit.cpp | 118 ++++++++++++------ olcCodeJam2023Entry/Unit.h | 51 +++++--- olcCodeJam2023Entry/VirusAttack.cpp | 71 +++++------ olcCodeJam2023Entry/VirusAttack.h | 3 +- olcCodeJam2023Entry/assets/attackLine.png | Bin 0 -> 641 bytes olcCodeJam2023Entry/assets/targetLine.png | Bin 0 -> 622 bytes .../olcCodeJam2023Entry.vcxproj | 1 + .../olcCodeJam2023Entry.vcxproj.filters | 3 + olcCodeJam2023Entry/olcPGEX_AudioListener.h | 6 +- olcCodeJam2023Entry/olcPGEX_AudioSource.h | 14 ++- olcCodeJam2023Entry/pge.data | Bin 476066 -> 448860 bytes olcCodeJam2023Entry/pge.js | 36 +++--- olcCodeJam2023Entry/pge.wasm | Bin 1438954 -> 1476470 bytes olcCodeJam2023Entry/util.cpp | 17 ++- olcCodeJam2023Entry/util.h | 2 + 20 files changed, 231 insertions(+), 122 deletions(-) create mode 100644 olcCodeJam2023Entry/Sound.h create mode 100644 olcCodeJam2023Entry/assets/attackLine.png create mode 100644 olcCodeJam2023Entry/assets/targetLine.png diff --git a/olcCodeJam2023Entry/Constant.cpp b/olcCodeJam2023Entry/Constant.cpp index a2d578f..ae6a951 100644 --- a/olcCodeJam2023Entry/Constant.cpp +++ b/olcCodeJam2023Entry/Constant.cpp @@ -14,4 +14,10 @@ vi2d CONSTANT::WORLD_SIZE={64,64}; float CONSTANT::SCROLL_BOUNDARY=36; -float CONSTANT::DEATH_FADE_TIME=1; \ No newline at end of file +float CONSTANT::DEATH_FADE_TIME=1; + +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}; \ No newline at end of file diff --git a/olcCodeJam2023Entry/Constant.h b/olcCodeJam2023Entry/Constant.h index 565e23f..26d54ea 100644 --- a/olcCodeJam2023Entry/Constant.h +++ b/olcCodeJam2023Entry/Constant.h @@ -20,4 +20,9 @@ public: static float SCROLL_BOUNDARY; static float DEATH_FADE_TIME; + + static Pixel ATTACKER_TARGET_COL; + static Pixel ATTACKER_ATTACK_COL; + static Pixel HEALER_TARGET_COL; + static Pixel HEALER_ATTACK_COL; }; \ No newline at end of file diff --git a/olcCodeJam2023Entry/Image.h b/olcCodeJam2023Entry/Image.h index 0a8a71c..df8c36d 100644 --- a/olcCodeJam2023Entry/Image.h +++ b/olcCodeJam2023Entry/Image.h @@ -24,5 +24,7 @@ enum Image{ PRC, RNG, SPD, + TARGETING_LINE, + ATTACKING_LINE, }; diff --git a/olcCodeJam2023Entry/Info.txt b/olcCodeJam2023Entry/Info.txt index a1cc2c7..6b1959f 100644 --- a/olcCodeJam2023Entry/Info.txt +++ b/olcCodeJam2023Entry/Info.txt @@ -23,7 +23,16 @@ Player build Memory Allocators using Resources. (HEALTH,RANGE,ATKSPD,MOVESPD,PROCEDURE) Memory Allocator costs 1/1/1/1/1. - +Day 4 Visuals/Clarity + Line Follow Indicators + Attacking Lines + Buff/Debuff Indicators +Day 5 Enemy AI / Resource Management + Collectors + (Or Day 7): Hotkeys +Day 6 Multiple Levels +Day 7 Tutorializing +Day 8 Customized Units +Day 9 Sounds/Music - Timer (Speedrun) Difficulty Selection Tutorial (Grey out non-important bars) diff --git a/olcCodeJam2023Entry/Sound.h b/olcCodeJam2023Entry/Sound.h new file mode 100644 index 0000000..8f49702 --- /dev/null +++ b/olcCodeJam2023Entry/Sound.h @@ -0,0 +1,5 @@ +#pragma once + +enum class Sound{ + HUM, +}; \ No newline at end of file diff --git a/olcCodeJam2023Entry/Unit.cpp b/olcCodeJam2023Entry/Unit.cpp index 80ec999..23c2ea0 100644 --- a/olcCodeJam2023Entry/Unit.cpp +++ b/olcCodeJam2023Entry/Unit.cpp @@ -1,70 +1,69 @@ #include "Unit.h" -#include "Constant.h" #include "olcUTIL_Geometry2D.h" #include "TileManager.h" #include "util.h" -BasicUnit::BasicUnit(vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) - :Unit({ +BasicUnit::BasicUnit(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) + :Unit(pge,{ {HEALTH,4}, {RANGE,2}, {ATKSPD,2}, {MOVESPD,3}, {PROCEDURE,1}, - },pos,12,*IMAGES[VIRUS_IMG1],friendly,moveable){} + },pos,12,*IMAGES[VIRUS_IMG1],WHITE,WHITE,friendly,moveable){} void BasicUnit::Attack(Unit&victim,std::vector>&otherUnits){ victim<<=1; } -BasicUnit2::BasicUnit2(vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) - :Unit({ +BasicUnit2::BasicUnit2(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) + :Unit(pge,{ {RANGE,2}, {ATKSPD,2}, {MOVESPD,3}, {PROCEDURE,1}, {HEALTH,4}, - },pos,12,*IMAGES[VIRUS_IMG1],friendly,moveable){} + },pos,12,*IMAGES[VIRUS_IMG1],WHITE,WHITE,friendly,moveable){} void BasicUnit2::Attack(Unit&victim,std::vector>&otherUnits){ victim>>=1; } -LeftShifter::LeftShifter(vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) - :Unit({ +LeftShifter::LeftShifter(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) + :Unit(pge,{ {RANGE,2}, {ATKSPD,2}, {MOVESPD,3}, {PROCEDURE,1}, {HEALTH,4}, - },pos,12,*IMAGES[LEFT_SHIFTER],friendly,moveable){} + },pos,12,*IMAGES[LEFT_SHIFTER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} void LeftShifter::Attack(Unit&victim,std::vector>&otherUnits){ victim<<=1; } -RightShifter::RightShifter(vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) - :Unit({ +RightShifter::RightShifter(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) + :Unit(pge,{ {HEALTH,4}, {RANGE,2}, {ATKSPD,2}, {MOVESPD,3}, {PROCEDURE,1}, - },pos,12,*IMAGES[RIGHT_SHIFTER],friendly,moveable){} + },pos,12,*IMAGES[RIGHT_SHIFTER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} void RightShifter::Attack(Unit&victim,std::vector>&otherUnits){ victim>>=1; } -BitRestorer::BitRestorer(vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) - :Unit({ +BitRestorer::BitRestorer(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) + :Unit(pge,{ {PROCEDURE,6}, {RANGE,1}, {ATKSPD,1}, {MOVESPD,1}, {HEALTH,2}, - },pos,12,*IMAGES[BIT_RESTORER],friendly,moveable,true,false){} + },pos,12,*IMAGES[BIT_RESTORER],CONSTANT::HEALER_TARGET_COL,CONSTANT::HEALER_ATTACK_COL,friendly,moveable,true,false){} void BitRestorer::Attack(Unit&victim,std::vector>&otherUnits){ std::vectoremptyMemoryPositions; @@ -75,6 +74,7 @@ void BitRestorer::Attack(Unit&victim,std::vector>&otherUni } if(emptyMemoryPositions.size()==0){ //First see if we can find another damaged target, if we can, then we try healing them. Otherwise we exit. + appliedTarget.reset(); AttemptToHealOtherAllies(otherUnits); return; } @@ -94,33 +94,36 @@ void BitRestorer::AttemptToHealOtherAllies(std::vector>&ot if(emptyMemoryPositions.size()!=0){ int randomBit=emptyMemoryPositions[rand()%emptyMemoryPositions.size()]; u->memory[randomBit]=u->ghostMemory[randomBit]=true; + appliedTarget=u; return; } } } } -MemorySwapper::MemorySwapper(vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) - :Unit({ +MemorySwapper::MemorySwapper(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) + :Unit(pge,{ {RANGE,3}, {ATKSPD,1}, {HEALTH,3}, {PROCEDURE,3}, {MOVESPD,2}, - },pos,12,*IMAGES[MEMORY_SWAPPER],friendly,moveable,true){} + },pos,12,*IMAGES[MEMORY_SWAPPER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable,true){ + autoAcquireFriendlyTarget=false; +} void MemorySwapper::Attack(Unit&victim,std::vector>&otherUnits){ } -Corrupter::Corrupter(vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) - :Unit({ +Corrupter::Corrupter(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) + :Unit(pge,{ {ATKSPD,3}, {RANGE,1}, {PROCEDURE,8}, {MOVESPD,4}, {HEALTH,4}, - },pos,12,*IMAGES[CORRUPTER],friendly,moveable){} + },pos,12,*IMAGES[CORRUPTER],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,moveable){} void Corrupter::Attack(Unit&victim,std::vector>&otherUnits){ //Chooses a bit at random and corrupts it. @@ -128,27 +131,27 @@ void Corrupter::Attack(Unit&victim,std::vector>&otherUnits victim.memory[randomBit]=victim.ghostMemory[randomBit]=false; } -MemoryAllocator::MemoryAllocator(vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) - :Unit({ +MemoryAllocator::MemoryAllocator(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly,bool moveable) + :Unit(pge,{ {RANGE,1}, {ATKSPD,1}, {MOVESPD,1}, {PROCEDURE,1}, {HEALTH,1}, - },pos,12,*IMAGES[UNIT_ALLOCATOR],friendly,true,false){} + },pos,12,*IMAGES[UNIT_ALLOCATOR],CONSTANT::ATTACKER_TARGET_COL,CONSTANT::ATTACKER_ATTACK_COL,friendly,true,false){} void MemoryAllocator::Attack(Unit&victim,std::vector>&otherUnits){ } RAMBank::RAMBank(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly) - :Unit({ + :Unit(pge,{ {RANGE,0}, {ATKSPD,0}, {MOVESPD,0}, {PROCEDURE,25}, {HEALTH,16}, - },pos,41,*IMAGES[RAM_BANK],friendly,false + },pos,41,*IMAGES[RAM_BANK],WHITE,WHITE,friendly,false ,false,false ),randomOffset({util::random(128),util::random(128)}),matrixImg(*IMAGES[MATRIX]), originalImg(*IMAGES[RAM_BANK]){ @@ -163,7 +166,7 @@ void RAMBank::Attack(Unit&victim,std::vector>&otherUnits){ } -void RAMBank::Update(PixelGameEngine*pge){ +void RAMBank::Update(PixelGameEngine*pge,std::map>&SOUNDS){ pge->SetDrawTarget(img.Sprite()); for(int y=0;yheight;y++){ for(int x=0;xwidth;x++){ @@ -173,6 +176,10 @@ void RAMBank::Update(PixelGameEngine*pge){ } } } + if(!soundStarted){ + soundStarted=true; + soundHandle=SOUNDS[Sound::HUM]->Play(GetPos(),0.4,0.4,true); + } img.Decal()->Update(); pge->SetDrawTarget(nullptr); } @@ -184,8 +191,12 @@ void RAMBank::Draw(TileTransformedView&game,std::mapmemory,vf2d pos,float radius,Renderable&img,bool friendly,bool moveable,bool friendlyInteractable,bool enemyInteractable) -:pos(pos),radius(radius),ghostPos(pos),img(img),friendly(friendly),moveable(moveable),friendlyInteractable(friendlyInteractable),enemyInteractable(enemyInteractable){ +void RAMBank::OnDeath(std::map>&SOUNDS){ + SOUNDS[Sound::HUM]->Stop(soundHandle); +} + +Unit::Unit(PixelGameEngine*pge,std::vectormemory,vf2d pos,float radius,Renderable&img,Pixel targetLineColor,Pixel attackingLineColor,bool friendly,bool moveable,bool friendlyInteractable,bool enemyInteractable) +:pos(pos),radius(radius),ghostPos(pos),img(img),targetLineCol(targetLineColor),attackingLineCol(attackingLineColor),friendly(friendly),moveable(moveable),friendlyInteractable(friendlyInteractable),enemyInteractable(enemyInteractable){ int marker=0; for(Memory&mem:memory){ for(int i=0;imemory,vf2d pos,float radius,Renderable&img,bool f } marker+=mem.size; } + + attackingLine.Create(25,24,false,false); + targetingLine.Create(25,24,false,false); } void Unit::DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::map>&IMAGES){ @@ -317,6 +331,23 @@ void Unit::DrawHud(TileTransformedView&game,std::map>&IMAGES){ + if(!target.expired()){ + geom2d::linelineToTarget(pos,target.lock()->pos); + lineToTarget.start=lineToTarget.rpoint(GetUnitSize().x/2); + lineToTarget.end=lineToTarget.rpoint(lineToTarget.length()-GetUnitSize().x/4); + util::ApplyMatrixEffect(game.GetPGE(),targetingLine,*IMAGES[TARGETING_LINE],IMAGES[MATRIX]); + game.DrawPartialRotatedDecal(lineToTarget.upoint(0.5),targetingLine.Decal(),lineToTarget.vector().polar().y,{lineToTarget.length()/2,12},{lineShift*10,0},{lineToTarget.length(),24},{1,1},targetLineCol); + } + if(!appliedTarget.expired()){ + geom2d::linelineToTarget(pos,appliedTarget.lock()->pos); + lineToTarget.start=lineToTarget.rpoint(GetUnitSize().x/2); + lineToTarget.end=lineToTarget.rpoint(lineToTarget.length()-GetUnitSize().x/4); + if(reloadTimer>0){ + util::ApplyMatrixEffect(game.GetPGE(),attackingLine,*IMAGES[ATTACKING_LINE],IMAGES[MATRIX]); + float reloadSpd=1.f/(GetAtkSpd()/2.f); + game.DrawPartialRotatedDecal(lineToTarget.upoint(0.5),attackingLine.Decal(),lineToTarget.vector().polar().y,{lineToTarget.length()/2,12},{lineShift*30,0},{lineToTarget.length(),24},{1,1+(reloadTimer/reloadSpd)*0.25f},{attackingLineCol.r,attackingLineCol.g,attackingLineCol.b,uint8_t(IsFriendly()?200:160)}); + } + } float dist=geom2d::line(game.ScreenToWorld(pge->GetMousePos()),GetGhostPos()).length(); float range=12*(GetRange()+1); @@ -325,7 +356,7 @@ void Unit::DrawUnitDamageStats(PixelGameEngine*pge,TileTransformedView&game,std: auto DrawStatDown=[&](Marker&maxStat,int currentStat,vf2d pos,vf2d downDisplayPos,Image img,uint8_t transparency=255){ if(maxStat.size>0){ if(currentStat!=maxStat.size){ - game.DrawDecal(this->pos+pos,IMAGES[img]->Decal(),{1,1},{255,255,255,transparency}); + game.DrawDecal(this->pos+pos,IMAGES[img]->Decal(),{1,1},currentStat==0?Pixel{192,64,64,transparency}:Pixel{255,255,255,transparency}); if(currentStat>0){ game.DrawDecal(this->pos+downDisplayPos,IMAGES[DOWN_ARROW]->Decal(),{1,1},{255,255,255,transparency}); } else { @@ -337,15 +368,15 @@ void Unit::DrawUnitDamageStats(PixelGameEngine*pge,TileTransformedView&game,std: if(IsSelected()){ DrawStatDown(atkSpd,GetAtkSpd(),{-48-8,-24},{-48+8,-18},RLD); - DrawStatDown(moveSpd,GetMoveSpd(),{-48-8,8},{-48+8,2},SPD); - DrawStatDown(this->range,GetRange(),{8,-24},{36,-18},RNG); - DrawStatDown(procedure,GetProcedure(),{8,8},{36,2},PRC); + DrawStatDown(moveSpd,GetMoveSpd(),{-48-8,8},{-36+8,2},SPD); + DrawStatDown(this->range,GetRange(),{8,-24},{20,-18},RNG); + DrawStatDown(procedure,GetProcedure(),{8,8},{26,2},PRC); }else if(distrange,GetRange(),{8,-24},{26,-18},RNG,transparency); + DrawStatDown(moveSpd,GetMoveSpd(),{-48-8,8},{-36+8,2},SPD,transparency); + DrawStatDown(this->range,GetRange(),{8,-24},{20,-18},RNG,transparency); DrawStatDown(procedure,GetProcedure(),{8,8},{26,2},PRC,transparency); } } @@ -360,6 +391,8 @@ int Unit::GetBits(Marker&m){ return activeBits; } +void Unit::OnDeath(std::map>&SOUNDS){} + int Unit::GetHealth(){ return GetBits(health); } @@ -390,7 +423,7 @@ void Unit::_RunAI(PixelGameEngine*pge){ RunAI(pge); } -void Unit::_Update(PixelGameEngine*pge){ +void Unit::_Update(PixelGameEngine*pge,std::map>&SOUNDS){ if(!target.expired()){ auto ptrTarget=target.lock(); if(!InRange(ptrTarget)){ @@ -413,8 +446,10 @@ void Unit::_Update(PixelGameEngine*pge){ } reloadTimer=std::max(0.f,reloadTimer-pge->GetElapsedTime()); + lineShift-=pge->GetElapsedTime(); + if(lineShift<-25)lineShift+=25; - Update(pge); + Update(pge,SOUNDS); } std::vector operator <<(Unit&u,const int n){ @@ -511,12 +546,13 @@ void Unit::AttemptAttack(std::weak_ptrattacker,std::weak_ptrunit,std } if(!finalTarget.expired()){ if(InRange(finalTarget.lock())){ + appliedTarget=finalTarget; _Attack(attacker,finalTarget,otherUnits); //Call the parent function first, followed by the child. } } } -void Unit::Update(PixelGameEngine*pge){} +void Unit::Update(PixelGameEngine*pge,std::map>&SOUNDS){} void Unit::Attacked(std::weak_ptrattacker){} @@ -574,4 +610,8 @@ Renderable&Unit::GetImage(){ std::weak_ptrUnit::GetCurrentTarget(){ return target; +} + +bool Unit::AutoAcquiresFriendlyTargets(){ + return autoAcquireFriendlyTarget; } \ No newline at end of file diff --git a/olcCodeJam2023Entry/Unit.h b/olcCodeJam2023Entry/Unit.h index f8a6473..1151c49 100644 --- a/olcCodeJam2023Entry/Unit.h +++ b/olcCodeJam2023Entry/Unit.h @@ -4,6 +4,9 @@ #include "olcPGEX_TransformedView.h" #include "Constant.h" #include "Image.h" +#include "Sound.h" +#include "olcPGEX_AudioSource.h" +#include "util.h" struct Marker{ size_t index; @@ -25,7 +28,7 @@ struct Memory{ struct Unit{ public: - Unit(std::vectormemory,vf2d pos,float radius,Renderable&img,bool friendly=false,bool moveable=true,bool friendlyInteractable=false,bool enemyInteractable=true); + Unit(PixelGameEngine*pge,std::vectormemory,vf2d pos,float radius,Renderable&img,Pixel targetLineColor,Pixel attackingLineColor,bool friendly=false,bool moveable=true,bool friendlyInteractable=false,bool enemyInteractable=true); int GetHealth(); int GetRange(); int GetAtkSpd(); @@ -34,10 +37,11 @@ public: int GetMemorySize(); std::vectormemory; std::vectorghostMemory; - virtual void Update(PixelGameEngine*pge); + virtual void Update(PixelGameEngine*pge,std::map>&SOUNDS); virtual void Attack(Unit&victim,std::vector>&otherUnits)=0; virtual void Draw(TileTransformedView&game,std::map>&IMAGES); virtual void DrawHud(TileTransformedView&game,std::map>&IMAGES); + virtual void OnDeath(std::map>&SOUNDS); bool IsFriendly(); bool IsSelected(); void Select(); @@ -53,7 +57,7 @@ public: bool GhostInFogOfWar(); void HideGhost(); vf2d GetGhostPos(); - void _Update(PixelGameEngine*pge); + void _Update(PixelGameEngine*pge,std::map>&SOUNDS); bool IsMoveable(); void DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::map>&IMAGES); bool CanInteractWithEnemies(); @@ -65,6 +69,7 @@ public: void _Attacked(std::weak_ptrattacker); std::weak_ptrGetCurrentTarget(); void DrawUnitDamageStats(PixelGameEngine*pge,TileTransformedView&game,std::map>&IMAGES); + bool AutoAcquiresFriendlyTargets(); std::vector& operator <<=(const int n){ for(int i=0;itarget; + std::weak_ptrappliedTarget; vf2d targetLoc=CONSTANT::UNSELECTED; bool InRange(std::shared_ptrtarget); bool InRange(Unit*target); bool InRange(vf2d pos); + float reloadTimer=0; + bool autoAcquireFriendlyTarget=true; private: + Renderable targetingLine; + Renderable attackingLine; + Pixel targetLineCol,attackingLineCol; vf2d pos; vf2d ghostPos; float radius; int GetBits(Marker&m); bool selected=false; bool dead=false; - float reloadTimer=0; void _Attack(std::weak_ptrattacker,std::weak_ptrfinalTarget,std::vector>&otherUnits); bool moveable=true; bool friendlyInteractable=false; bool enemyInteractable=true; + float lineShift=0; + void ApplyMatrixEffect(Renderable&r); }; struct BasicUnit:Unit{ - BasicUnit(vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); + BasicUnit(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); void Attack(Unit&victim,std::vector>&otherUnits)override; }; struct BasicUnit2:Unit{ - BasicUnit2(vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); + BasicUnit2(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); void Attack(Unit&victim,std::vector>&otherUnits)override; }; struct LeftShifter:Unit{ - LeftShifter(vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); + LeftShifter(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); void Attack(Unit&victim,std::vector>&otherUnits)override; }; struct RightShifter:Unit{ - RightShifter(vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); + RightShifter(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); void Attack(Unit&victim,std::vector>&otherUnits)override; }; struct BitRestorer:Unit{ - BitRestorer(vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); + BitRestorer(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); void Attack(Unit&victim,std::vector>&otherUnits)override; void AttemptToHealOtherAllies(std::vector>&otherUnits); }; struct MemorySwapper:Unit{ - MemorySwapper(vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); + MemorySwapper(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); void Attack(Unit&victim,std::vector>&otherUnits)override; }; struct Corrupter:Unit{ - Corrupter(vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); + Corrupter(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); void Attack(Unit&victim,std::vector>&otherUnits)override; }; struct MemoryAllocator:Unit{ - MemoryAllocator(vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); + MemoryAllocator(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly=false,bool moveable=true); void Attack(Unit&victim,std::vector>&otherUnits)override; }; @@ -160,8 +172,11 @@ struct RAMBank:Unit{ Renderable img; Renderable&originalImg; Renderable&matrixImg; + bool soundStarted=false; + int soundHandle; RAMBank(PixelGameEngine*pge,vf2d pos,std::map>&IMAGES,bool friendly=false); - void Update(PixelGameEngine*pge)override; + void Update(PixelGameEngine*pge,std::map>&SOUNDS)override; void Attack(Unit&victim,std::vector>&otherUnits)override; void Draw(TileTransformedView&game,std::map>&IMAGES)override; + void OnDeath(std::map>&SOUNDS)override; }; \ No newline at end of file diff --git a/olcCodeJam2023Entry/VirusAttack.cpp b/olcCodeJam2023Entry/VirusAttack.cpp index 92112e5..010da65 100644 --- a/olcCodeJam2023Entry/VirusAttack.cpp +++ b/olcCodeJam2023Entry/VirusAttack.cpp @@ -40,6 +40,8 @@ void VirusAttack::InitializeImages(){ LoadImage(PRC,"assets/prc.png"); LoadImage(RNG,"assets/rng.png"); LoadImage(SPD,"assets/spd.png"); + LoadImage(TARGETING_LINE,"assets/targetLine.png"); + LoadImage(ATTACKING_LINE,"assets/attackLine.png"); } bool VirusAttack::OnUserCreate(){ @@ -59,13 +61,13 @@ bool VirusAttack::OnUserCreate(){ AL.AudioSystemInit(); InitializeSounds(); - units.push_back(std::make_unique(vf2d{128,128},IMAGES,true)); - units.push_back(std::make_unique(vf2d{129,129},IMAGES,true)); - units.push_back(std::make_unique(vf2d{130,130},IMAGES,true)); - units.push_back(std::make_unique(vf2d{130,140},IMAGES,true)); - units.push_back(std::make_unique(vf2d{131,131},IMAGES,true)); - units.push_back(std::make_unique(vf2d{132,132},IMAGES,true)); - units.push_back(std::make_unique(vf2d{133,133},IMAGES,true)); + units.push_back(std::make_unique(this,vf2d{128,128},IMAGES,true)); + units.push_back(std::make_unique(this,vf2d{129,129},IMAGES,true)); + units.push_back(std::make_unique(this,vf2d{130,130},IMAGES,true)); + units.push_back(std::make_unique(this,vf2d{130,140},IMAGES,true)); + units.push_back(std::make_unique(this,vf2d{131,131},IMAGES,true)); + units.push_back(std::make_unique(this,vf2d{132,132},IMAGES,true)); + units.push_back(std::make_unique(this,vf2d{133,133},IMAGES,true)); units.push_back(std::make_unique(this,vf2d{134,134},IMAGES,true)); @@ -74,30 +76,25 @@ bool VirusAttack::OnUserCreate(){ collectionPoints.push_back(std::make_unique(this,vf2d{32.f,32.f+48*i},-PI/2,*IMAGES[MEMORY_COLLECTION_POINT],MemoryType(i))); } - units.push_back(std::make_unique(this,vf2d{320,320},IMAGES,false)); + units.push_back(std::make_unique(this,vf2d{1200,1200},IMAGES,false)); - units.push_back(std::make_unique(vf2d{360,300},IMAGES,false)); - - for(int i=0;iGetMemorySize();i++){ - units[0]->memory[i]=units[0]->ghostMemory[i]=i%2==0; - } + units.push_back(std::make_unique(this,vf2d{1260,1200},IMAGES,false)); + units.push_back(std::make_unique(this,vf2d{360,300},IMAGES,false)); + units.push_back(std::make_unique(this,vf2d{361,300},IMAGES,false)); return true; } void VirusAttack::InitializeSounds(){ int soundIndex=0; - auto LoadSound=[&](Audio&audio,std::string soundFilename){ - audio.AL=&AL; - audio.LoadAudioSample(soundIndex,std::string("./assets/"+soundFilename).c_str()); + auto LoadSound=[&](Sound sound,std::string soundFilename){ + SOUNDS[sound]=std::make_unique