Condense functions.

CorrectiveAction
sigonasr2 1 year ago
parent 4a6847a0cf
commit bf61fa77b4
  1. 8
      olcCodeJam2023Entry/ImageManager.h
  2. 18
      olcCodeJam2023Entry/VirusAttack.cpp
  3. 2
      olcCodeJam2023Entry/VirusAttack.h

@ -0,0 +1,8 @@
#pragma once
#include "olcPixelGameEngine.h"
class ImageManager{
public:
Renderable VIRUS_IMG1;
Renderable SELECTION_CIRCLE;
};

@ -27,8 +27,7 @@ bool VirusAttack::OnUserCreate(){
return true;
}
bool VirusAttack::OnUserUpdate(float fElapsedTime){
// Called once per frame, draws random coloured pixels
void VirusAttack::HandleDraggingSelection(){
if(GetMouse(0).bPressed){
for(std::unique_ptr<Unit>&u:units){
u->Deselect();
@ -51,6 +50,16 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
}
startingDragPos=CONSTANT::UNSELECTED;
}
}
void VirusAttack::DrawSelectionRectangle(){
if(startingDragPos!=CONSTANT::UNSELECTED){
FillRectDecal(startingDragPos,GetMousePos()-startingDragPos,{255,255,0,128});
}
}
bool VirusAttack::OnUserUpdate(float fElapsedTime){
HandleDraggingSelection();
for(std::unique_ptr<Unit>&u:units){
u->Update(fElapsedTime);
@ -60,9 +69,8 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){
u->Draw(this);
}
if(startingDragPos!=CONSTANT::UNSELECTED){
FillRectDecal(startingDragPos,GetMousePos()-startingDragPos,{255,255,0,128});
}
DrawSelectionRectangle();
return true;
}

@ -8,6 +8,8 @@ private:
std::vector<std::unique_ptr<Unit>>units;
vf2d startingDragPos=CONSTANT::UNSELECTED;
void HandleDraggingSelection();
void DrawSelectionRectangle();
public:
VirusAttack();

Loading…
Cancel
Save