generated from sigonasr2/CPlusPlusProjectTemplate
Draw channeling position ranges
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
c99aed13db
commit
9a509bf76f
Binary file not shown.
61
main.cpp
61
main.cpp
@ -342,7 +342,9 @@ namespace Battle{
|
||||
Move(std::string name,std::string desc,int baseDmg,int randomDmg,int PPCost,int range,int channelTime,bool friendly,std::array<int,4>composition,Effect*eff=nullptr,bool pctDamage=false,std::vector<std::pair<Property,int>> properties={})
|
||||
:Move(name,desc,0,baseDmg,randomDmg,PPCost,range,channelTime,friendly,composition,eff,pctDamage,properties){};
|
||||
Move(std::string name,std::string desc,int grade,int baseDmg,int randomDmg,int PPCost,int range,int channelTime,bool friendly,std::array<int,4>composition,Effect*eff=nullptr,bool pctDamage=false,std::vector<std::pair<Property,int>> properties={})
|
||||
:name(name),grade(grade),PPCost(PPCost),desc(desc),randomDmg(randomDmg),baseDmg(baseDmg),range(range),friendly(friendly),eff(eff),channelTime(channelTime),composition(composition),pctDamage(pctDamage),properties(properties){}
|
||||
:name(name),grade(grade),PPCost(PPCost),desc(desc),randomDmg(randomDmg),baseDmg(baseDmg),range(range),friendly(friendly),eff(eff),channelTime(channelTime),composition(composition),pctDamage(pctDamage),properties(properties){
|
||||
this->channelTime=180;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -367,6 +369,7 @@ class Entity{
|
||||
int selectedTarget = 0;
|
||||
Battle::Move*selectedMove = nullptr; //The index of the selected move.
|
||||
int channelTimeRemaining = 0; //The amount of channel time left until move can be performed.
|
||||
vd2d channelPos = {0,0}; //Where are channel is happening.
|
||||
//Used for initializing players.
|
||||
Entity(int HP,int maxHP,int PP,int maxPP,int baseAtk,std::array<int,4>resistances,int speed,std::vector<Battle::Move*>moveSet,int damageReduction=0,bool smart=false,bool dumb=false)
|
||||
:Entity(nullptr,HP,maxHP,PP,maxPP,baseAtk,resistances,speed,moveSet,damageReduction,smart,dumb){}
|
||||
@ -1115,6 +1118,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
SELECTED_TARGET=-4;
|
||||
}
|
||||
} while (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-SELECTED_TARGET-1]]->GetHP()<=0&&!getProperty(Property::REVIVE,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove));
|
||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-SELECTED_TARGET-1]]->obj->GetPosWithOrigin();
|
||||
} else {
|
||||
do {
|
||||
SELECTED_TARGET--;
|
||||
@ -1122,6 +1126,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
SELECTED_TARGET=BATTLE_ENCOUNTER->objs.size()-1;
|
||||
}
|
||||
} while (BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->GetHP()<=0);
|
||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos=BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->obj->GetPosWithOrigin();
|
||||
}
|
||||
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
|
||||
PARTY_MEMBER_OBJ[i]->highlighted=false;
|
||||
@ -1141,10 +1146,12 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
SELECTED_TARGET=-1;
|
||||
}
|
||||
} while (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-SELECTED_TARGET-1]]->GetHP()<=0&&!getProperty(Property::REVIVE,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove));
|
||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-SELECTED_TARGET-1]]->obj->GetPosWithOrigin();
|
||||
} else {
|
||||
do {
|
||||
SELECTED_TARGET=(SELECTED_TARGET+1)%BATTLE_ENCOUNTER->objs.size();
|
||||
} while (BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->GetHP()<=0);
|
||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->channelPos=BATTLE_ENCOUNTER->objs[SELECTED_TARGET]->obj->GetPosWithOrigin();
|
||||
}
|
||||
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
|
||||
PARTY_MEMBER_OBJ[i]->highlighted=false;
|
||||
@ -1311,6 +1318,21 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
for (auto&obj:OBJECTS) {
|
||||
obj->drawn=false;
|
||||
}
|
||||
if (BATTLE_ENCOUNTER!=nullptr) {
|
||||
SetDrawTarget(layer::DYNAMIC);
|
||||
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
|
||||
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->selectedMove!=nullptr&&PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->channelTimeRemaining>0&&PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->selectedMove->friendly) {
|
||||
DrawTargetRangeGrid(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->channelPos,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->selectedMove->range,
|
||||
Pixel(0,128,0,255),Pixel(0,128,0,64),Pixel(90,200,90,64),true);
|
||||
}
|
||||
}
|
||||
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
|
||||
if (BATTLE_ENCOUNTER->objs[i]->selectedMove!=nullptr&&BATTLE_ENCOUNTER->objs[i]->channelTimeRemaining>0&&!BATTLE_ENCOUNTER->objs[i]->selectedMove->friendly) {
|
||||
DrawTargetRangeGrid(BATTLE_ENCOUNTER->objs[i]->channelPos,BATTLE_ENCOUNTER->objs[i]->selectedMove->range,
|
||||
Pixel(128,0,0,255),Pixel(128,0,0,64),Pixel(200,90,90,64),true);
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (GAME_STATE) {
|
||||
case GameState::GAME_WORLD:{
|
||||
DrawGameWorld();
|
||||
@ -2887,6 +2909,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
do {
|
||||
BATTLE_ENCOUNTER->objs[i]->selectedTarget=rand()%BATTLE_ENCOUNTER->objs.size();
|
||||
} while (BATTLE_ENCOUNTER->objs[BATTLE_ENCOUNTER->objs[i]->selectedTarget]->GetHP()<=0);
|
||||
BATTLE_ENCOUNTER->objs[i]->channelPos=BATTLE_ENCOUNTER->objs[BATTLE_ENCOUNTER->objs[i]->selectedTarget]->obj->GetPosWithOrigin();
|
||||
} else {
|
||||
bool playerAlive=false;
|
||||
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
|
||||
@ -2899,6 +2922,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
do {
|
||||
BATTLE_ENCOUNTER->objs[i]->selectedTarget=-(rand()%PARTY_MEMBER_COUNT)-1;
|
||||
} while (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-BATTLE_ENCOUNTER->objs[i]->selectedTarget-1]]->GetHP()<=0);
|
||||
BATTLE_ENCOUNTER->objs[i]->channelPos=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-BATTLE_ENCOUNTER->objs[i]->selectedTarget-1]]->obj->GetPosWithOrigin();
|
||||
printf("Selected Target: %d\n",BATTLE_ENCOUNTER->objs[i]->selectedTarget);
|
||||
}
|
||||
}
|
||||
@ -3222,7 +3246,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
return ents;
|
||||
}
|
||||
|
||||
void DrawTargetRangeGrid(vd2d pos,int range) {
|
||||
void DrawTargetRangeGrid(vd2d pos,int range,Pixel outlinecol,Pixel box1col,Pixel box2col,bool connectedborder) {
|
||||
vi2d gridCenter = (vi2d)pos/32*32;
|
||||
for (int x=-range+1;x<range;x++) {
|
||||
for (int y=-range+1;y<range;y++) {
|
||||
@ -3230,15 +3254,42 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
if (dist<range) {
|
||||
vi2d offset = {x,y};
|
||||
//FillRectDecal(gridCenter-cameraPos+offset*32,{32,32},Pixel(255,255,0,128));
|
||||
GradientFillRectDecal(gridCenter-cameraPos+offset*32,{32,32},Pixel(0,161,255,abs(sin(M_PI/240*frameCount)*32)),Pixel(139,234,255,abs(sin(M_PI/240*frameCount)*64)),Pixel(0,161,255,abs(sin(M_PI/240*frameCount)*32)),Pixel(139,234,255,abs(sin(M_PI/240*frameCount)*64)));
|
||||
DrawRectDecal(gridCenter-cameraPos+offset*32,{32,32},Pixel(abs(cos(M_PI/240*frameCount)*128),200,0,255));
|
||||
GradientFillRectDecal(gridCenter-cameraPos+offset*32,{32,32},box1col,box2col,box1col,box2col);
|
||||
const vi2d outlineOffset = {1,1};
|
||||
DrawRectDecal(gridCenter-cameraPos+offset*32+outlineOffset,{30,30},Pixel(abs(cos(M_PI/240*frameCount)*128),200,0,255));
|
||||
if (!connectedborder) {
|
||||
DrawRectDecal(gridCenter-cameraPos+offset*32,{32,32},outlinecol);
|
||||
DrawRectDecal(gridCenter-cameraPos+offset*32+outlineOffset,{30,30},outlinecol);
|
||||
} else {
|
||||
vd2d pos=gridCenter-cameraPos+offset*32;
|
||||
vd2d pos2=gridCenter-cameraPos+offset*32+outlineOffset;
|
||||
vd2d size={32,32};
|
||||
vd2d size2={30,30};
|
||||
if (abs(x)+abs(y-1)>=range) {
|
||||
DrawLineDecal(pos,{pos.x+size.x,pos.y},outlinecol); //Top
|
||||
DrawLineDecal(pos2,{pos2.x+size2.x,pos2.y},outlinecol); //Top
|
||||
}
|
||||
if (abs(x-1)+abs(y)>=range) {
|
||||
DrawLineDecal({pos.x,pos.y},{pos.x,pos.y+size.y},outlinecol); //Left
|
||||
DrawLineDecal({pos2.x,pos2.y},{pos2.x,pos2.y+size2.y},outlinecol); //Left
|
||||
}
|
||||
if (abs(x)+abs(y+1)>=range) {
|
||||
DrawLineDecal({pos.x,pos.y+size.y},{pos.x+size.x,pos.y+size.y},outlinecol); //Bottom
|
||||
DrawLineDecal({pos2.x,pos2.y+size2.y},{pos2.x+size2.x,pos2.y+size2.y},outlinecol); //Bottom
|
||||
}
|
||||
if (abs(x+1)+abs(y)>=range) {
|
||||
DrawLineDecal({pos.x+size.x,pos.y},{pos.x+size.x,pos.y+size.y},outlinecol); //Right
|
||||
DrawLineDecal({pos2.x+size2.x,pos2.y},{pos2.x+size2.x,pos2.y+size2.y},outlinecol); //Right
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawTargetRangeGrid(vd2d pos,int range) {
|
||||
DrawTargetRangeGrid(pos,range,Pixel(abs(cos(M_PI/240*frameCount)*128),200,0,255),Pixel(0,161,255,abs(sin(M_PI/240*frameCount)*32)),Pixel(139,234,255,abs(sin(M_PI/240*frameCount)*64)),false);
|
||||
}
|
||||
|
||||
vi2d grid(int x, int y) {
|
||||
return {x*32,y*32};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user