Fix range display issues, make right click holding a thing for smoother movement.
This commit is contained in:
parent
15a08e8b9f
commit
40238e67a6
@ -11,7 +11,7 @@ BasicUnit::BasicUnit(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES
|
|||||||
{ATKSPD,2},
|
{ATKSPD,2},
|
||||||
{MOVESPD,3},
|
{MOVESPD,3},
|
||||||
{PROCEDURE,1},
|
{PROCEDURE,1},
|
||||||
},pos,*IMAGES[VIRUS_IMG1],friendly,moveable){}
|
},pos,12,*IMAGES[VIRUS_IMG1],friendly,moveable){}
|
||||||
|
|
||||||
|
|
||||||
void BasicUnit::Attack(Unit&victim){
|
void BasicUnit::Attack(Unit&victim){
|
||||||
@ -25,7 +25,7 @@ BasicUnit2::BasicUnit2(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAG
|
|||||||
{MOVESPD,3},
|
{MOVESPD,3},
|
||||||
{PROCEDURE,1},
|
{PROCEDURE,1},
|
||||||
{HEALTH,4},
|
{HEALTH,4},
|
||||||
},pos,*IMAGES[VIRUS_IMG1],friendly,moveable){}
|
},pos,12,*IMAGES[VIRUS_IMG1],friendly,moveable){}
|
||||||
|
|
||||||
void BasicUnit2::Attack(Unit&victim){
|
void BasicUnit2::Attack(Unit&victim){
|
||||||
victim>>=1;
|
victim>>=1;
|
||||||
@ -38,7 +38,7 @@ LeftShifter::LeftShifter(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IM
|
|||||||
{MOVESPD,3},
|
{MOVESPD,3},
|
||||||
{PROCEDURE,1},
|
{PROCEDURE,1},
|
||||||
{HEALTH,4},
|
{HEALTH,4},
|
||||||
},pos,*IMAGES[LEFT_SHIFTER],friendly,moveable){}
|
},pos,12,*IMAGES[LEFT_SHIFTER],friendly,moveable){}
|
||||||
|
|
||||||
void LeftShifter::Attack(Unit&victim){
|
void LeftShifter::Attack(Unit&victim){
|
||||||
victim<<=1;
|
victim<<=1;
|
||||||
@ -51,7 +51,7 @@ RightShifter::RightShifter(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&
|
|||||||
{ATKSPD,2},
|
{ATKSPD,2},
|
||||||
{MOVESPD,3},
|
{MOVESPD,3},
|
||||||
{PROCEDURE,1},
|
{PROCEDURE,1},
|
||||||
},pos,*IMAGES[RIGHT_SHIFTER],friendly,moveable){}
|
},pos,12,*IMAGES[RIGHT_SHIFTER],friendly,moveable){}
|
||||||
|
|
||||||
void RightShifter::Attack(Unit&victim){
|
void RightShifter::Attack(Unit&victim){
|
||||||
victim>>=1;
|
victim>>=1;
|
||||||
@ -64,7 +64,7 @@ BitRestorer::BitRestorer(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IM
|
|||||||
{ATKSPD,1},
|
{ATKSPD,1},
|
||||||
{MOVESPD,1},
|
{MOVESPD,1},
|
||||||
{HEALTH,2},
|
{HEALTH,2},
|
||||||
},pos,*IMAGES[BIT_RESTORER],friendly,moveable){}
|
},pos,12,*IMAGES[BIT_RESTORER],friendly,moveable){}
|
||||||
|
|
||||||
void BitRestorer::Attack(Unit&victim){
|
void BitRestorer::Attack(Unit&victim){
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ MemorySwapper::MemorySwapper(vf2d pos,std::map<Image,std::unique_ptr<Renderable>
|
|||||||
{HEALTH,3},
|
{HEALTH,3},
|
||||||
{PROCEDURE,3},
|
{PROCEDURE,3},
|
||||||
{MOVESPD,2},
|
{MOVESPD,2},
|
||||||
},pos,*IMAGES[MEMORY_SWAPPER],friendly,moveable){}
|
},pos,12,*IMAGES[MEMORY_SWAPPER],friendly,moveable){}
|
||||||
|
|
||||||
void MemorySwapper::Attack(Unit&victim){
|
void MemorySwapper::Attack(Unit&victim){
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ Corrupter::Corrupter(vf2d pos,std::map<Image,std::unique_ptr<Renderable>>&IMAGES
|
|||||||
{PROCEDURE,8},
|
{PROCEDURE,8},
|
||||||
{MOVESPD,4},
|
{MOVESPD,4},
|
||||||
{HEALTH,4},
|
{HEALTH,4},
|
||||||
},pos,*IMAGES[CORRUPTER],friendly,moveable){}
|
},pos,12,*IMAGES[CORRUPTER],friendly,moveable){}
|
||||||
|
|
||||||
void Corrupter::Attack(Unit&victim){
|
void Corrupter::Attack(Unit&victim){
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ MemoryAllocator::MemoryAllocator(vf2d pos,std::map<Image,std::unique_ptr<Rendera
|
|||||||
{MOVESPD,1},
|
{MOVESPD,1},
|
||||||
{PROCEDURE,1},
|
{PROCEDURE,1},
|
||||||
{HEALTH,1},
|
{HEALTH,1},
|
||||||
},pos,*IMAGES[UNIT_ALLOCATOR],friendly){}
|
},pos,12,*IMAGES[UNIT_ALLOCATOR],friendly){}
|
||||||
|
|
||||||
void MemoryAllocator::Attack(Unit&victim){
|
void MemoryAllocator::Attack(Unit&victim){
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ RAMBank::RAMBank(PixelGameEngine*pge,vf2d pos,std::map<Image,std::unique_ptr<Ren
|
|||||||
{MOVESPD,0},
|
{MOVESPD,0},
|
||||||
{PROCEDURE,25},
|
{PROCEDURE,25},
|
||||||
{HEALTH,16},
|
{HEALTH,16},
|
||||||
},pos,*IMAGES[RAM_BANK],friendly,false),randomOffset({util::random(128),util::random(128)}),matrixImg(*IMAGES[MATRIX]),
|
},pos,41,*IMAGES[RAM_BANK],friendly,false),randomOffset({util::random(128),util::random(128)}),matrixImg(*IMAGES[MATRIX]),
|
||||||
originalImg(*IMAGES[RAM_BANK]){
|
originalImg(*IMAGES[RAM_BANK]){
|
||||||
img.Create(IMAGES[RAM_BANK]->Sprite()->width,IMAGES[RAM_BANK]->Sprite()->height);
|
img.Create(IMAGES[RAM_BANK]->Sprite()->width,IMAGES[RAM_BANK]->Sprite()->height);
|
||||||
pge->SetDrawTarget(img.Sprite());
|
pge->SetDrawTarget(img.Sprite());
|
||||||
@ -150,8 +150,8 @@ void RAMBank::Draw(TileTransformedView&game,std::map<Image,std::unique_ptr<Rende
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Unit::Unit(std::vector<Memory>memory,vf2d pos,Renderable&img,bool friendly,bool moveable)
|
Unit::Unit(std::vector<Memory>memory,vf2d pos,float radius,Renderable&img,bool friendly,bool moveable)
|
||||||
:pos(pos),ghostPos(pos),img(img),friendly(friendly),moveable(moveable){
|
:pos(pos),radius(radius),ghostPos(pos),img(img),friendly(friendly),moveable(moveable){
|
||||||
int marker=0;
|
int marker=0;
|
||||||
for(Memory&mem:memory){
|
for(Memory&mem:memory){
|
||||||
for(int i=0;i<mem.size;i++){
|
for(int i=0;i<mem.size;i++){
|
||||||
@ -185,13 +185,20 @@ Unit::Unit(std::vector<Memory>memory,vf2d pos,Renderable&img,bool friendly,bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Unit::DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){
|
void Unit::DrawRangeIndicator(PixelGameEngine*pge,TileTransformedView&game,std::map<Image,std::unique_ptr<Renderable>>&IMAGES){
|
||||||
float dist=geom2d::line<float>(game.ScreenToWorld(pge->GetMousePos()),GetPos()).length();
|
float dist=geom2d::line<float>(game.ScreenToWorld(pge->GetMousePos()),GetGhostPos()).length();
|
||||||
float range=12*(GetRange()+1);
|
float range=12*(GetRange()+1);
|
||||||
|
float totalRange=GetUnitSize().x/2+range;
|
||||||
if(IsSelected()){
|
if(IsSelected()){
|
||||||
game.DrawRotatedDecal(GetPos(),IMAGES[RANGE_INDICATOR]->Decal(),0,IMAGES[RANGE_INDICATOR]->Sprite()->Size()/2,{range/12,range/12},{0,196,0,128});
|
game.DrawRotatedDecal(GetGhostPos(),IMAGES[RANGE_INDICATOR]->Decal(),0,IMAGES[RANGE_INDICATOR]->Sprite()->Size()/2,{totalRange/12,totalRange/12},{0,196,0,128});
|
||||||
}else
|
}else
|
||||||
if(dist<range*2){
|
if(dist<range*2){
|
||||||
game.DrawRotatedDecal(GetPos(),IMAGES[RANGE_INDICATOR]->Decal(),0,IMAGES[RANGE_INDICATOR]->Sprite()->Size()/2,{range/12,range/12},{0,196,0,uint8_t((1.f-(dist/(range*2)))*128)});
|
Pixel col;
|
||||||
|
if(IsFriendly()){
|
||||||
|
col={0,196,0};
|
||||||
|
}else{
|
||||||
|
col={196,130,0};
|
||||||
|
}
|
||||||
|
game.DrawRotatedDecal(GetGhostPos(),IMAGES[RANGE_INDICATOR]->Decal(),0,IMAGES[RANGE_INDICATOR]->Sprite()->Size()/2,{totalRange/12,totalRange/12},{col.r,col.g,col.b,uint8_t((1.f-(dist/(range*2)))*128)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,7 +366,7 @@ bool Unit::IsDead(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
vf2d Unit::GetUnitSize(){
|
vf2d Unit::GetUnitSize(){
|
||||||
return img.Sprite()->Size();
|
return vf2d{radius,radius}*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::SetTargetUnit(std::weak_ptr<Unit>target){
|
void Unit::SetTargetUnit(std::weak_ptr<Unit>target){
|
||||||
|
@ -25,7 +25,7 @@ struct Memory{
|
|||||||
|
|
||||||
struct Unit{
|
struct Unit{
|
||||||
public:
|
public:
|
||||||
Unit(std::vector<Memory>memory,vf2d pos,Renderable&img,bool friendly=false,bool moveable=true);
|
Unit(std::vector<Memory>memory,vf2d pos,float radius,Renderable&img,bool friendly=false,bool moveable=true);
|
||||||
int GetHealth();
|
int GetHealth();
|
||||||
int GetRange();
|
int GetRange();
|
||||||
int GetAtkSpd();
|
int GetAtkSpd();
|
||||||
@ -91,6 +91,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
vf2d pos;
|
vf2d pos;
|
||||||
vf2d ghostPos;
|
vf2d ghostPos;
|
||||||
|
float radius;
|
||||||
int GetBits(Marker&m);
|
int GetBits(Marker&m);
|
||||||
bool selected=false;
|
bool selected=false;
|
||||||
bool dead=false;
|
bool dead=false;
|
||||||
|
@ -106,7 +106,7 @@ void VirusAttack::DrawSelectionRectangle(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VirusAttack::HandleRightClickMove(){
|
void VirusAttack::HandleRightClickMove(){
|
||||||
if (GetMouse(1).bPressed){
|
if (GetMouse(1).bHeld){
|
||||||
bool selectedTarget=false;
|
bool selectedTarget=false;
|
||||||
for(auto&u:units){
|
for(auto&u:units){
|
||||||
if(!u->IsFriendly()){
|
if(!u->IsFriendly()){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user