Fixed Range indicator issues and reduced attack range stat to be 2 per point.

CorrectiveAction
sigonasr2 1 year ago
parent d233afe975
commit 88d9dea027
  1. 9
      olcCodeJam2023Entry/Info.txt
  2. 24
      olcCodeJam2023Entry/Unit.cpp
  3. 1
      olcCodeJam2023Entry/Unit.h
  4. 7
      olcCodeJam2023Entry/VirusAttack.cpp

@ -14,6 +14,15 @@ Attack Speed: 1/(AtkSpd/2) attacks per second
Range/Attack indicators
System has limited resources, both sides fight for resources.
Add Bar
Quantify Resource Limits
Start off w/5 of each resource.
Player build Memory Allocators using Resources.
(HEALTH,RANGE,ATKSPD,MOVESPD,PROCEDURE)
Memory Allocator costs 1/1/1/1/1.
Tutorial

@ -28,7 +28,7 @@ BasicUnit2::BasicUnit2(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAG
},pos,*IMAGES[VIRUS_IMG1],friendly,moveable){}
void BasicUnit2::Attack(Unit&victim){
victim>>=1;
}
LeftShifter::LeftShifter(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable)
@ -41,7 +41,7 @@ LeftShifter::LeftShifter(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IM
},pos,*IMAGES[LEFT_SHIFTER],friendly,moveable){}
void LeftShifter::Attack(Unit&victim){
victim<<=1;
}
RightShifter::RightShifter(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable)
@ -54,7 +54,7 @@ RightShifter::RightShifter(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&
},pos,*IMAGES[RIGHT_SHIFTER],friendly,moveable){}
void RightShifter::Attack(Unit&victim){
victim>>=1;
}
BitRestorer::BitRestorer(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES,bool friendly,bool moveable)
@ -266,8 +266,6 @@ void Unit::_Update(PixelGameEngine*pge){
auto ptrTarget=target.lock();
if(!InRange(ptrTarget)){
SetPos(GetPos()+(ptrTarget->GetPos()-pos).norm()*GetMoveSpd()*24*pge->GetElapsedTime());
} else {
//TODO Attack here.
}
} else
if(targetLoc!=CONSTANT::UNSELECTED){
@ -366,13 +364,19 @@ void Unit::SetTargetLocation(vf2d targetLoc){
}
bool Unit::InRange(std::shared_ptr<Unit>target){
float dist=geom2d::line(GetPos(),target->GetPos()).length();
return dist<24*(GetRange()+1);
return InRange(target.get());
}
bool Unit::InRange(Unit*target){
float range=12*(GetRange()+1);
float totalRange=GetUnitSize().x/2+range;
return geom2d::overlaps(geom2d::circle<float>{GetPos(),totalRange},geom2d::circle<float>{target->GetPos(),target->GetUnitSize().x/2});
}
bool Unit::InRange(vf2d pos){
float dist=geom2d::line(GetPos(),pos).length();
return dist<24*(GetRange()+1);
float range=12*(GetRange()+1);
float totalRange=GetUnitSize().x/2+range;
return geom2d::overlaps(geom2d::circle<float>{GetPos(),totalRange},geom2d::circle<float>{pos,0.1});
}
void Unit::SetPos(vf2d newPos){
@ -395,7 +399,7 @@ void Unit::AttemptAttack(Unit*unit){
}
}
if(finalTarget!=nullptr){
if(InRange(finalTarget->GetPos())){
if(InRange(finalTarget)){
_Attack(finalTarget); //Call the parent function first, followed by the child.
}
}

@ -94,6 +94,7 @@ private:
bool selected=false;
bool dead=false;
bool InRange(std::shared_ptr<Unit>target);
bool InRange(Unit*target);
bool InRange(vf2d pos);
float reloadTimer=0;
void _Attack(Unit*finalTarget);

@ -61,6 +61,8 @@ bool VirusAttack::OnUserCreate(){
collectionPoints.push_back(std::make_unique<CollectionPoint>(this,vf2d{32.f,32.f+48*i},-PI/2,*IMAGES[MEMORY_COLLECTION_POINT],MemoryType(i)));
}
units.push_back(std::make_unique<RAMBank>(this,vf2d{320,320},IMAGES,false));
return true;
}
@ -163,7 +165,10 @@ void VirusAttack::DrawMinimap(){
Clear(BLANK);
DrawRect((game.GetWorldOffset()/worldPixelSize*64),viewingTilesPct*64/game.GetWorldScale());
for(auto&u:units){
FillRect(u->GetGhostPos()/worldPixelSize*64,vf2d{2,2}*u->GetUnitSize()/24,u->IsFriendly()?GREEN:RED);
vf2d squareSize=u->GetUnitSize()/vf2d(CONSTANT::WORLD_SIZE);
squareSize.x=std::round(std::max(1.f,squareSize.x));
squareSize.y=std::round(std::max(1.f,squareSize.y));
FillRect(u->GetGhostPos()/worldPixelSize*64-squareSize,squareSize*2,u->IsFriendly()?GREEN:RED);
}
IMAGES[MINIMAP_OUTLINE]->Decal()->Update();
SetDrawTarget(nullptr);

Loading…
Cancel
Save