Re-did healthbar displays.

CorrectiveAction
sigonasr2 1 year ago
parent 79afdeadc7
commit 38f23b3374
  1. 2
      olcCodeJam2023Entry/Constant.cpp
  2. 8
      olcCodeJam2023Entry/Image.h
  3. 23
      olcCodeJam2023Entry/Unit.cpp
  4. 19
      olcCodeJam2023Entry/VirusAttack.cpp
  5. BIN
      olcCodeJam2023Entry/assets/atk.png
  6. BIN
      olcCodeJam2023Entry/assets/down_arrow.png
  7. BIN
      olcCodeJam2023Entry/assets/prc.png
  8. BIN
      olcCodeJam2023Entry/assets/red_x.png
  9. BIN
      olcCodeJam2023Entry/assets/rld.png
  10. BIN
      olcCodeJam2023Entry/assets/rng.png
  11. BIN
      olcCodeJam2023Entry/assets/spd.png

@ -1,6 +1,6 @@
#include "Constant.h"
vf2d CONSTANT::BAR_SQUARE_SIZE={4,4};
vf2d CONSTANT::BAR_SQUARE_SIZE={1,4};
Pixel CONSTANT::HEALTH_COLOR={235, 210, 52};
Pixel CONSTANT::RANGE_COLOR={52, 235, 89};
Pixel CONSTANT::ATKSPD_COLOR={140, 21, 13};

@ -17,6 +17,12 @@ enum Image{
CORRUPTER,
UNIT_ALLOCATOR,
RAM_BANK,
RANGE_INDICATOR
RANGE_INDICATOR,
DOWN_ARROW,
RED_X,
RLD,
PRC,
RNG,
SPD,
};

@ -135,7 +135,7 @@ MemoryAllocator::MemoryAllocator(vf2d pos,std::map<Image,std::unique_ptr<Rendera
{MOVESPD,1},
{PROCEDURE,1},
{HEALTH,1},
},pos,12,*IMAGES[UNIT_ALLOCATOR],friendly,false,false){}
},pos,12,*IMAGES[UNIT_ALLOCATOR],friendly,true,false){}
void MemoryAllocator::Attack(Unit&victim,std::vector<std::shared_ptr<Unit>>&otherUnits){
@ -282,6 +282,27 @@ void Unit::DrawHud(TileTransformedView&game,std::map<Image,std::unique_ptr<Rende
}
};
if(GetHealth()>0){
game.FillRectDecal(vf2d{float(initialBarX)+health.index*CONSTANT::BAR_SQUARE_SIZE.x,
float(initialBarY)}-vf2d{0,1},CONSTANT::BAR_SQUARE_SIZE+vf2d{CONSTANT::BAR_SQUARE_SIZE.x*health.size-1,2},CONSTANT::HEALTH_COLOR);
}
if(GetAtkSpd()>0){
game.FillRectDecal(vf2d{float(initialBarX)+atkSpd.index*CONSTANT::BAR_SQUARE_SIZE.x,
float(initialBarY)}-vf2d{0,1},CONSTANT::BAR_SQUARE_SIZE+vf2d{CONSTANT::BAR_SQUARE_SIZE.x*atkSpd.size-1,2},CONSTANT::ATKSPD_COLOR);
}
if(GetMoveSpd()>0){
game.FillRectDecal(vf2d{float(initialBarX)+moveSpd.index*CONSTANT::BAR_SQUARE_SIZE.x,
float(initialBarY)}-vf2d{0,1},CONSTANT::BAR_SQUARE_SIZE+vf2d{CONSTANT::BAR_SQUARE_SIZE.x*moveSpd.size-1,2},CONSTANT::MOVESPD_COLOR);
}
if(GetProcedure()>0){
game.FillRectDecal(vf2d{float(initialBarX)+procedure.index*CONSTANT::BAR_SQUARE_SIZE.x,
float(initialBarY)}-vf2d{0,1},CONSTANT::BAR_SQUARE_SIZE+vf2d{CONSTANT::BAR_SQUARE_SIZE.x*procedure.size-1,2},CONSTANT::PROCEDURE_COLOR);
}
if(GetRange()>0){
game.FillRectDecal(vf2d{float(initialBarX)+range.index*CONSTANT::BAR_SQUARE_SIZE.x,
float(initialBarY)}-vf2d{0,1},CONSTANT::BAR_SQUARE_SIZE+vf2d{CONSTANT::BAR_SQUARE_SIZE.x*range.size-1,2},CONSTANT::RANGE_COLOR);
}
for(int i=0;i<GetMemorySize();i++){
CheckColor(i,col);

@ -34,6 +34,12 @@ void VirusAttack::InitializeImages(){
LoadImage(UNIT_ALLOCATOR,"assets/shell.png");
LoadImage(RAM_BANK,"assets/ram_bank.png");
LoadImage(RANGE_INDICATOR,"assets/range_indicator.png");
LoadImage(DOWN_ARROW,"assets/down_arrow.png");
LoadImage(RED_X,"assets/red_x.png");
LoadImage(RLD,"assets/rld.png");
LoadImage(PRC,"assets/prc.png");
LoadImage(RNG,"assets/rng.png");
LoadImage(SPD,"assets/spd.png");
}
bool VirusAttack::OnUserCreate(){
@ -107,9 +113,17 @@ void VirusAttack::HandleDraggingSelection(){
if(endDragPos.x<startingDragPos.x){std::swap(startingDragPos.x,endDragPos.x);}
if(endDragPos.y<startingDragPos.y){std::swap(startingDragPos.y,endDragPos.y);}
geom2d::rect<float> selectionRegion(startingDragPos,endDragPos-startingDragPos);
if(selectionRegion.size.x<12){
selectionRegion.pos.x-=12-selectionRegion.size.x/2;
selectionRegion.size.x+=12-selectionRegion.size.x/2;
}
if(selectionRegion.size.y<12){
selectionRegion.pos.y-=12-selectionRegion.size.y/2;
selectionRegion.size.y+=12-selectionRegion.size.y/2;
}
for(auto&u:units){
if(u->IsFriendly()){
if(geom2d::overlaps(selectionRegion,u->GetPos())){
if(geom2d::overlaps(selectionRegion,geom2d::circle<float>(u->GetPos(),u->GetUnitSize().x/2))){
u->Select();
}
}
@ -328,9 +342,6 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
HandleMinimapClick();
AL.vecPos=game.GetWorldOffset()+GetScreenSize()/2;
AL.OnUserUpdate(fElapsedTime);
if (GetKey(olc::Key::P).bPressed){
AS_Test.Play({0,0},1,1);
}
for(auto&tile:TileManager::visibleTiles){
tile.second-=fElapsedTime;

Binary file not shown.

After

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

Loading…
Cancel
Save