Highlight targets that are selected

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent fceb8a9005
commit 5f37838fc1
  1. BIN
      C++ProjectTemplate
  2. 115
      main.cpp

Binary file not shown.

@ -102,6 +102,7 @@ class Object{
bool dead=false; //If set to true, this object was properly part of an Entity and got declared as dead.
int blinkFrames=0; //Frame count of how much time is left for the image to be blinking. Used when enemies take damage.
//animationSpd is how long to wait before switching frames.
bool highlighted=false; //Whether or not this object has been declared as highlighted by a target range selector.
bool Collision(vd2d pos) {
GAME->SetDrawTarget(layer::COLLISION);
Pixel collisionData = GAME->GetDrawTarget()->GetPixel((int)pos.x-cameraPos.x,(int)pos.y-cameraPos.y);
@ -628,6 +629,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
drawGame();
return true;
}
void GetAnyKeyPress() override {
if (messageBoxVisible) {
if (messageBoxMarker==messageBoxFinalText.length()) {
@ -1073,6 +1075,15 @@ goes on a very long time, I hope you can understand this is only for testing pur
}
} while (BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->GetHP()<=0);
}
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
PARTY_MEMBER_OBJ[i]->highlighted=false;
}
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
BATTLE_ENCOUNTER->objs[i]->obj->highlighted=false;
}
for (auto&ent:GetEntitiesInRange(SELECTED_TARGET,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
ent->obj->highlighted=true;
}
}
if (RightPressed()) {
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->friendly) {
@ -1087,19 +1098,40 @@ goes on a very long time, I hope you can understand this is only for testing pur
SELECTED_TARGET=(SELECTED_TARGET+1)%BATTLE_ENCOUNTER->objs.size();
} while (BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->GetHP()<=0);
}
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
PARTY_MEMBER_OBJ[i]->highlighted=false;
}
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
BATTLE_ENCOUNTER->objs[i]->obj->highlighted=false;
}
for (auto&ent:GetEntitiesInRange(SELECTED_TARGET,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
ent->obj->highlighted=true;
}
}
if (UpPressed()) {
if (BATTLE_SELECTION_CURSOR==0) { //Power was selected, so go back to the powers menu.
BATTLE_STATE = BattleState::GRADE_SELECT;
BATTLE_STATE=BattleState::GRADE_SELECT;
} else { //This was a standard attack, go back to main menu.
BATTLE_STATE=BattleState::SELECT_ACTION;
}
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
PARTY_MEMBER_OBJ[i]->highlighted=false;
}
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
BATTLE_ENCOUNTER->objs[i]->obj->highlighted=false;
}
}
if (ACTIONKEYPRESSED) {
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget=SELECTED_TARGET;
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove==nullptr) { //We have to check for this because other actions will need a target select and will override this.
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove=BATTLE_MOVELIST_DISPLAY[POWER_SELECTION_CURSOR[-CURRENT_TURN-1]][POWER_GRADE_CURSOR[-CURRENT_TURN-1]];
}
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
PARTY_MEMBER_OBJ[i]->highlighted=false;
}
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
BATTLE_ENCOUNTER->objs[i]->obj->highlighted=false;
}
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelTimeRemaining=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->channelTime;
BATTLE_STATE=BattleState::WAIT;
}
@ -1550,8 +1582,40 @@ goes on a very long time, I hope you can understand this is only for testing pur
obj->blinkFrames--;
}
if (obj->blinkFrames==0||obj->blinkFrames>0&&obj->blinkFrames%3==0) {
SetDrawTarget(layer::DYNAMIC);
DrawPartialDecal(obj->GetPos()-cameraPos,obj->spr->spr,{(float)((obj->frameIndex%obj->spr->frames)*obj->spr->width),0},{(float)obj->spr->width,(float)obj->spr->spr->sprite->height},obj->GetScale(),obj->color);
if (obj->highlighted) {
SetDrawTarget(layer::HIGH);
Pixel*data = obj->spr->spr->sprite->GetData();
double accX=0;
double accY=0;
int pixelOffsetX=0;
int pixelOffsetY=0;
for (int xx=0;xx<obj->spr->width;xx++) {
accX+=obj->GetScale().x;
for (int yy=0;yy<obj->spr->spr->sprite->height;yy++) {
accY+=obj->GetScale().y;
Pixel col = data[yy*96+xx+((obj->frameIndex%obj->spr->frames)*obj->spr->width)];
while (accY>=1) {
for (int xxx=0;xxx<accX;xxx++) {
if (col.a>64) {
GetDrawTarget()->SetPixel(obj->GetPos().x-cameraPos.x+pixelOffsetX+xxx,obj->GetPos().y-cameraPos.y+pixelOffsetY,Pixel(255,255,255,abs(sin(M_PI/60*frameCount)*210)));
}
}
accY-=1;
pixelOffsetY++;
}
}
while (accX>=1) {
accX-=1;
pixelOffsetX++;
}
pixelOffsetY=0;
}
SetDrawTarget(layer::DYNAMIC);
DrawPartialDecal(obj->GetPos()-cameraPos,obj->spr->spr,{(float)((obj->frameIndex%obj->spr->frames)*obj->spr->width),0},{(float)obj->spr->width,(float)obj->spr->spr->sprite->height},obj->GetScale(),obj->color);
} else {
SetDrawTarget(layer::DYNAMIC);
DrawPartialDecal(obj->GetPos()-cameraPos,obj->spr->spr,{(float)((obj->frameIndex%obj->spr->frames)*obj->spr->width),0},{(float)obj->spr->width,(float)obj->spr->spr->sprite->height},obj->GetScale(),obj->color);
}
}
}
}
@ -1893,18 +1957,18 @@ goes on a very long time, I hope you can understand this is only for testing pur
MOVELIST[BattleMoveName::TESTMOVE2]=new Battle::Move("Test Move 2","An attack",40,10, 0,1,0,false,{0,0,0,0});
MOVELIST[BattleMoveName::TESTMOVE3]=new Battle::Move("Test Move 3","An attack",25,5, 0,1,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::BASH]=new Battle::Move("Bash","Regular attack.",5,5, 0,1,0,false,{0,0,0,0});
MOVELIST[BattleMoveName::HAILSTORM_A]=new Battle::Move("Hailstorm","Causes heavy ice rocks to crash",ALPHA,40,20, 4,10,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::HAILSTORM_B]=new Battle::Move("Hailstorm","Causes heavy ice rocks to crash",BETA,80,20, 12,10,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::HAILSTORM_G]=new Battle::Move("Hailstorm","Causes heavy ice rocks to crash",GAMMA,120,20, 28,10,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::HAILSTORM_O]=new Battle::Move("Hailstorm","Causes heavy ice rocks to crash",OMEGA,210,50, 69,10,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::HURRICANE_A]=new Battle::Move("Hurricane","Scatters seeds, causes heavy rains and winds",ALPHA,25,5, 7,14,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::HURRICANE_B]=new Battle::Move("Hurricane","Scatters seeds, causes heavy rains and winds",BETA,45,5, 13,14,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::HURRICANE_G]=new Battle::Move("Hurricane","Scatters seeds, causes heavy rains and winds",GAMMA,75,10, 25,20,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::HURRICANE_O]=new Battle::Move("Hurricane","Scatters seeds, causes heavy rains and winds",OMEGA,125,20, 55,20,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::METEORRAIN_A]=new Battle::Move("Meteor Rain","Causes fiery rocks to fall from the skies. Chance to burn trees.",ALPHA,60,10, 10,6,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::METEORRAIN_B]=new Battle::Move("Meteor Rain","Causes fiery rocks to fall from the skies. Chance to burn trees.",BETA,110,30, 22,6,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::METEORRAIN_G]=new Battle::Move("Meteor Rain","Causes fiery rocks to fall from the skies. Chance to burn trees.",GAMMA,200,50, 47,6,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::METEORRAIN_O]=new Battle::Move("Meteor Rain","Causes fiery rocks to fall from the skies. Chance to burn trees.",OMEGA,390,60, 98,6,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::HAILSTORM_A]=new Battle::Move("Hailstorm","Causes heavy ice rocks to crash",ALPHA,40,20, 4,4,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::HAILSTORM_B]=new Battle::Move("Hailstorm","Causes heavy ice rocks to crash",BETA,80,20, 12,4,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::HAILSTORM_G]=new Battle::Move("Hailstorm","Causes heavy ice rocks to crash",GAMMA,120,20, 28,4,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::HAILSTORM_O]=new Battle::Move("Hailstorm","Causes heavy ice rocks to crash",OMEGA,210,50, 69,4,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::HURRICANE_A]=new Battle::Move("Hurricane","Scatters seeds, causes heavy rains and winds",ALPHA,25,5, 7,6,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::HURRICANE_B]=new Battle::Move("Hurricane","Scatters seeds, causes heavy rains and winds",BETA,45,5, 13,6,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::HURRICANE_G]=new Battle::Move("Hurricane","Scatters seeds, causes heavy rains and winds",GAMMA,75,10, 25,8,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::HURRICANE_O]=new Battle::Move("Hurricane","Scatters seeds, causes heavy rains and winds",OMEGA,125,20, 55,8,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::METEORRAIN_A]=new Battle::Move("Meteor Rain","Causes fiery rocks to fall from the skies. Chance to burn trees.",ALPHA,60,10, 10,2,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::METEORRAIN_B]=new Battle::Move("Meteor Rain","Causes fiery rocks to fall from the skies. Chance to burn trees.",BETA,110,30, 22,2,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::METEORRAIN_G]=new Battle::Move("Meteor Rain","Causes fiery rocks to fall from the skies. Chance to burn trees.",GAMMA,200,50, 47,2,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::METEORRAIN_O]=new Battle::Move("Meteor Rain","Causes fiery rocks to fall from the skies. Chance to burn trees.",OMEGA,390,60, 98,2,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFREEZE_A]=new Battle::Move("PK Freeze","A powerful chilling attack causing frostbite and slow.",ALPHA,80,10, 4,1,0,false,{0,0,20,10});
MOVELIST[BattleMoveName::PKFREEZE_B]=new Battle::Move("PK Freeze","A powerful chilling attack causing frostbite and slow.",BETA,120,20, 8,1,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFREEZE_G]=new Battle::Move("PK Freeze","A powerful chilling attack causing frostbite and slow.",GAMMA,240,40, 12,1,0,false,{0,0,20,0});
@ -1916,15 +1980,15 @@ goes on a very long time, I hope you can understand this is only for testing pur
MOVELIST[BattleMoveName::PKLIFEUP_A]=new Battle::Move("PK Lifeup","Restores a small amount of health.",ALPHA,80,10, 4,1,0,true,{0,0,20,0});
MOVELIST[BattleMoveName::PKLIFEUP_B]=new Battle::Move("PK Lifeup","Restores a moderate amount of health.",BETA,240,60, 9,1,0,true,{0,0,20,0});
MOVELIST[BattleMoveName::PKLIFEUP_G]=new Battle::Move("PK Lifeup","Restores a large amount of health.",GAMMA,400,50, 21,3,0,true,{0,0,20,0});
MOVELIST[BattleMoveName::PKLIFEUP_O]=new Battle::Move("PK Lifeup","Restores a great amount of health to all allies.",OMEGA,800,100, 64,10,0,true,{0,0,20,0});
MOVELIST[BattleMoveName::PKFUN_A]=new Battle::Move("PK Fun","A very fun barrage. Hits for large damage.",ALPHA,100,10, 15,12,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFUN_B]=new Battle::Move("PK Fun","A very fun barrage. Hits for large damage.",BETA,240,40, 30,12,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFUN_G]=new Battle::Move("PK Fun","A very fun barrage. Hits for large damage.",GAMMA,360,80, 45,20,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFUN_O]=new Battle::Move("PK Fun","A very fun barrage. Hits for large damage.",OMEGA,590,100, 90,30,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFIRE_A]=new Battle::Move("PK Fire","Causes extreme heat to burn foes and scorch trees",ALPHA,60,20, 6,4,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFIRE_B]=new Battle::Move("PK Fire","Causes extreme heat to burn foes and scorch trees",BETA,120,40, 12,6,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFIRE_G]=new Battle::Move("PK Fire","Causes extreme heat to burn foes and scorch trees",GAMMA,190,50, 20,10,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFIRE_O]=new Battle::Move("PK Fire","Causes extreme heat to burn foes and scorch trees",OMEGA,360,100, 32,12,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKLIFEUP_O]=new Battle::Move("PK Lifeup","Restores a great amount of health to all allies.",OMEGA,800,100, 64,6,0,true,{0,0,20,0});
MOVELIST[BattleMoveName::PKFUN_A]=new Battle::Move("PK Fun","A very fun barrage. Hits for large damage.",ALPHA,100,10, 15,6,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFUN_B]=new Battle::Move("PK Fun","A very fun barrage. Hits for large damage.",BETA,240,40, 30,6,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFUN_G]=new Battle::Move("PK Fun","A very fun barrage. Hits for large damage.",GAMMA,360,80, 45,7,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFUN_O]=new Battle::Move("PK Fun","A very fun barrage. Hits for large damage.",OMEGA,590,100, 90,8,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFIRE_A]=new Battle::Move("PK Fire","Causes extreme heat to burn foes and scorch trees",ALPHA,60,20, 6,3,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFIRE_B]=new Battle::Move("PK Fire","Causes extreme heat to burn foes and scorch trees",BETA,120,40, 12,4,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFIRE_G]=new Battle::Move("PK Fire","Causes extreme heat to burn foes and scorch trees",GAMMA,190,50, 20,5,0,false,{0,0,20,0});
MOVELIST[BattleMoveName::PKFIRE_O]=new Battle::Move("PK Fire","Causes extreme heat to burn foes and scorch trees",OMEGA,360,100, 32,7,0,false,{0,0,20,0});
}
void SetupAnimations() {
@ -3047,6 +3111,9 @@ goes on a very long time, I hope you can understand this is only for testing pur
}
}
}
for (auto&ent:GetEntitiesInRange(SELECTED_TARGET,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) {
ent->obj->highlighted=true;
}
}
std::vector<Entity*> GetEntitiesInRange(int targetEnt,Battle::Move*move) {

Loading…
Cancel
Save