Minimap clicking and memory swapper bug fixes.

CorrectiveAction
sigonasr2 1 year ago
parent 777ac29087
commit 7208181b25
  1. 1
      olcCodeJam2023Entry/Info.txt
  2. 34
      olcCodeJam2023Entry/Unit.cpp
  3. 6
      olcCodeJam2023Entry/Unit.h
  4. 12
      olcCodeJam2023Entry/VirusAttack.cpp

@ -34,6 +34,7 @@ Day 6 Multiple Levels
Day 7 Scenario Writing
Hotkeys
Day 8 Scenario Writing
Fake allies the narrator forgot to switch ovr
(Customized Units...?)
Day 9 Sounds/Music/Menus - Timer (Speedrun) Difficulty Selection
Ending...Shows Four Seasons of Loneliness boss zoom out...

@ -46,7 +46,7 @@ void BitRestorer::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUni
return;
}
int randomBit=emptyMemoryPositions[rand()%emptyMemoryPositions.size()];
victim.memory[randomBit]=victim.ghostMemory[randomBit]=true;
victim.memory[randomBit]=true;
}
void BitRestorer::AttemptToHealOtherAllies(std::vector<std::shared_ptr<Unit>>&otherUnits){
@ -60,7 +60,7 @@ void BitRestorer::AttemptToHealOtherAllies(std::vector<std::shared_ptr<Unit>>&ot
}
if(emptyMemoryPositions.size()!=0){
int randomBit=emptyMemoryPositions[rand()%emptyMemoryPositions.size()];
u->memory[randomBit]=u->ghostMemory[randomBit]=true;
u->memory[randomBit]=true;
appliedTarget=u;
return;
}
@ -79,12 +79,12 @@ MemorySwapper::MemorySwapper(PixelGameEngine*pge,vf2d pos,std::map<Image,std::un
void MemorySwapper::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){
std::vector<bool>oldMemory=victim.memory;
for(int i=0;i<oldMemory.size();i++){
victim.memory[i]=victim.ghostMemory[i]=oldMemory[oldMemory.size()-i-1];
victim.memory[i]=oldMemory[oldMemory.size()-i-1];
}
std::vector<Marker*>order;
for(int i=0;i<5;i++){
int lowestInd=999999;
Marker*lowest;
Marker*lowest=nullptr;
if(victim.health.index<lowestInd){lowest=&victim.health;lowestInd=lowest->index;}
if(victim.range.index<lowestInd){lowest=&victim.range;lowestInd=lowest->index;}
if(victim.atkSpd.index<lowestInd){lowest=&victim.atkSpd;lowestInd=lowest->index;}
@ -102,6 +102,12 @@ void MemorySwapper::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherU
marker+=order[i]->size;
i++;
}
//Clean up after ourselves for any 0-sized stats.
if(victim.health.index==9999999)victim.health.index=0;
if(victim.range.index==9999999)victim.range.index=0;
if(victim.atkSpd.index==9999999)victim.atkSpd.index=0;
if(victim.moveSpd.index==9999999)victim.moveSpd.index=0;
if(victim.procedure.index==9999999)victim.procedure.index=0;
}
std::string Corrupter::unitName="Corrupter";
@ -113,7 +119,7 @@ Corrupter::Corrupter(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr
void Corrupter::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){
//Chooses a bit at random and corrupts it.
int randomBit=rand()%victim.memory.size();
victim.memory[randomBit]=victim.ghostMemory[randomBit]=false;
victim.memory[randomBit]=false;
}
std::string MemoryAllocator::unitName="Memory Allocator";
@ -291,7 +297,7 @@ Refresher::Refresher(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr
void Refresher::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){
//Chooses a bit at random and corrupts it.
int randomBit=rand()%victim.memory.size();
victim.memory[randomBit]=victim.ghostMemory[randomBit]=false;
victim.memory[randomBit]=false;
}
std::string Turret::unitName="Turret";
@ -303,7 +309,7 @@ Turret::Turret(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Rende
void Turret::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){
//Chooses a bit at random and corrupts it.
int randomBit=rand()%victim.memory.size();
victim.memory[randomBit]=victim.ghostMemory[randomBit]=false;
victim.memory[randomBit]=false;
}
std::string MemoryGuard::unitName="Memory Guard";
@ -412,19 +418,19 @@ void Unit::_DrawHud(TileTransformedView&game,std::map<Image,std::unique_ptr<Rend
auto CheckColor=[&](int i,Pixel&col){
if(health.index==i){
if(health.index==i&&health.size>0){
col=CONSTANT::HEALTH_COLOR;
}
if(range.index==i){
if(range.index==i&&range.size>0){
col=CONSTANT::RANGE_COLOR;
}
if(atkSpd.index==i){
if(atkSpd.index==i&&atkSpd.size>0){
col=CONSTANT::ATKSPD_COLOR;
}
if(moveSpd.index==i){
if(moveSpd.index==i&&moveSpd.size>0){
col=CONSTANT::MOVESPD_COLOR;
}
if(procedure.index==i){
if(procedure.index==i&&procedure.size>0){
col=CONSTANT::PROCEDURE_COLOR;
}
};
@ -616,6 +622,10 @@ void Unit::_Update(PixelGameEngine*pge,std::map<Sound,std::unique_ptr<Audio>>&SO
HideGhost();
}
if(!InFogOfWar()){
ghostMemory=memory;
}
reloadTimer=std::max(0.f,reloadTimer-pge->GetElapsedTime());
guardTime=std::max(0.f,guardTime-pge->GetElapsedTime());
lineShift-=pge->GetElapsedTime();

@ -106,9 +106,6 @@ public:
memory[i]=memory[i+1];
}
memory[GetMemorySize()-1]=0;
if(!InFogOfWar()){
ghostMemory=memory;
}
return memory;
}
@ -117,9 +114,6 @@ public:
memory[i]=memory[i-1];
}
memory[0]=0;
if(!InFogOfWar()){
ghostMemory=memory;
}
return memory;
}
protected:

@ -336,6 +336,16 @@ void VirusAttack::DrawSelectionRectangle(){
void VirusAttack::HandleRightClickMove(){
if (GetMouse(1).bHeld){
bool selectedTarget=false;
if(GetMouseX()>=ScreenWidth()-64&&GetMouseY()>=ScreenHeight()-64){//Clicked on Minimap.
for(auto&u:units){
if(u->IsFriendly()&&u->IsSelected()&&u->CanMove()){
vf2d minimapTL=GetScreenSize()-vf2d{64,64};
vf2d minimapCenterClick=vf2d(GetMousePos()-minimapTL)/64*WORLD_SIZE*CONSTANT::TILE_SIZE-vf2d(GetScreenSize())/game.GetWorldScale()/2.f+vf2d(GetScreenSize()/2.f)/game.GetWorldScale();
u->SetTargetLocation(minimapCenterClick);
}
}
goto targetFound;
}
for(auto&u:units){
if(geom2d::overlaps(geom2d::circle<float>(u->GetPos(),u->GetUnitSize().x/2),GetWorldMousePos())){
for(auto&u2:units){
@ -680,7 +690,7 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
}
}
if(changeOccured&&util::random(1)<=0.3){
u->memory[changedBit]=u->ghostMemory[changedBit]=u->savedMemory[changedBit];
u->memory[changedBit]=u->savedMemory[changedBit];
}
}
}

Loading…
Cancel
Save