generated from sigonasr2/CPlusPlusProjectTemplate
Display of battle boxes onscreen
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
a02db5c33f
commit
e267d7ab98
Binary file not shown.
176
main.cpp
176
main.cpp
@ -20,6 +20,7 @@
|
||||
#define TILEMAP_EDITOR_TILESIZE (32*TILEMAP_EDITOR_DRAW_MULT)
|
||||
#define PARTY_TRAIL_LENGTH 48
|
||||
#define CAMERA_WAIT_TIME 60
|
||||
#define HEALTH_ROLLING_SPEED 1
|
||||
|
||||
#define ㅎ
|
||||
#define ㅍ
|
||||
@ -361,6 +362,7 @@ public:
|
||||
int OBJ_DISPLAY_OFFSET = 0;
|
||||
bool GAME_FLAGS[128]={};
|
||||
std::array<Object*,4> PARTY_MEMBER_OBJ;
|
||||
std::array<int,4> PARTY_MEMBER_ID;
|
||||
std::array<Entity*,7> PARTY_MEMBER_STATS;
|
||||
bool messageBoxVisible=false;
|
||||
std::string messageBoxText="";
|
||||
@ -389,6 +391,8 @@ public:
|
||||
int CAMERA_WAIT_TIMER=0;
|
||||
int player_rollhp_counter[4][3] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0}};
|
||||
int player_rollpp_counter[4][3] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0}};
|
||||
int player_rollhp_display[4][3] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0}};
|
||||
int player_rollpp_display[4][3] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0}};
|
||||
|
||||
|
||||
bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things.
|
||||
@ -540,12 +544,91 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
if (allDone) {
|
||||
CAMERA_WAIT_TIMER++;
|
||||
if (CAMERA_WAIT_TIMER>=CAMERA_WAIT_TIME) {
|
||||
BATTLE_STATE=BattleState::WAIT;
|
||||
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
|
||||
Entity*member=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]];
|
||||
for (int j=0;j<3;j++) {
|
||||
switch (j) {
|
||||
case 0:{
|
||||
player_rollhp_display[i][j]=member->HP%10;
|
||||
player_rollpp_display[i][j]=member->PP%10;
|
||||
}break;
|
||||
case 1:{
|
||||
player_rollhp_display[i][j]=member->HP/10%10;
|
||||
player_rollpp_display[i][j]=member->PP/10%10;
|
||||
}break;
|
||||
case 2:{
|
||||
player_rollhp_display[i][j]=member->HP/100%10;
|
||||
player_rollpp_display[i][j]=member->PP/100%10;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
BATTLE_STATE=BattleState::WAIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case BattleState::WAIT:{
|
||||
|
||||
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
|
||||
Entity*member=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]];
|
||||
if (member->HP>member->targetHP) {
|
||||
if (player_rollhp_counter[i][0]<=0) {
|
||||
player_rollhp_display[i][0]--;
|
||||
player_rollhp_counter[i][0]=13;
|
||||
member->HP--;
|
||||
if (player_rollhp_display[i][0]<0) {
|
||||
player_rollhp_display[i][0]=9;
|
||||
player_rollhp_counter[i][0]=13;
|
||||
player_rollhp_display[i][1]--;
|
||||
player_rollhp_counter[i][1]=13;
|
||||
if (player_rollhp_display[i][1]<0) {
|
||||
player_rollhp_display[i][1]=9;
|
||||
player_rollhp_counter[i][1]=13;
|
||||
player_rollhp_display[i][2]--;
|
||||
player_rollhp_counter[i][2]=13;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (player_rollhp_counter[i][0]>0) {
|
||||
player_rollhp_counter[i][0]-=HEALTH_ROLLING_SPEED;
|
||||
}
|
||||
if (player_rollhp_counter[i][1]>0) {
|
||||
player_rollhp_counter[i][1]--;
|
||||
}
|
||||
if (player_rollhp_counter[i][2]>0) {
|
||||
player_rollhp_counter[i][2]--;
|
||||
}
|
||||
} else
|
||||
if (member->HP<member->targetHP) {
|
||||
if (player_rollhp_counter[i][0]>=13) {
|
||||
player_rollhp_display[i][0]++;
|
||||
player_rollhp_counter[i][0]=0;
|
||||
member->HP++;
|
||||
if (player_rollhp_display[i][0]>9) {
|
||||
player_rollhp_display[i][0]=0;
|
||||
player_rollhp_counter[i][0]=0;
|
||||
player_rollhp_display[i][1]++;
|
||||
player_rollhp_counter[i][1]=0;
|
||||
if (player_rollhp_display[i][1]>9) {
|
||||
player_rollhp_display[i][1]=0;
|
||||
player_rollhp_counter[i][1]=0;
|
||||
player_rollhp_display[i][2]++;
|
||||
player_rollhp_counter[i][2]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (player_rollhp_counter[i][0]<13) {
|
||||
player_rollhp_counter[i][0]+=HEALTH_ROLLING_SPEED;
|
||||
}
|
||||
if (player_rollhp_counter[i][1]<13) {
|
||||
player_rollhp_counter[i][1]++;
|
||||
}
|
||||
if (player_rollhp_counter[i][2]<13) {
|
||||
player_rollhp_counter[i][2]++;
|
||||
}
|
||||
} else {
|
||||
player_rollhp_counter[i][0]=player_rollhp_counter[i][1]=player_rollhp_counter[i][2]=0;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
@ -1132,6 +1215,42 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
}break;
|
||||
}
|
||||
if (BATTLE_ENCOUNTER!=nullptr) {
|
||||
switch (BATTLE_STATE) {
|
||||
case BattleState::MOVE_CAMERA:{
|
||||
|
||||
}break;
|
||||
default:{
|
||||
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
|
||||
Entity*member=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]];
|
||||
Object*obj=PARTY_MEMBER_OBJ[i];
|
||||
const olc::vi2d box = {(128-32*PARTY_MEMBER_COUNT)+i*64,160};
|
||||
drawCheckerboardBox(box,{59,59},olc::Pixel(180,159,194),olc::Pixel(200,179,214),{6,6});
|
||||
DrawStringDecal({(float)(box.x+6),(float)(box.y+6)},obj->name,olc::BLACK);
|
||||
const olc::vi2d hpTextPos = {box.x+5,box.y+25};
|
||||
for (int x=-1;x<=1;x++) {
|
||||
for (int y=-1;y<=1;y++) {
|
||||
if (x!=0&&y!=0) {
|
||||
DrawStringDecal({(float)(hpTextPos.x+x),(float)(hpTextPos.y+y)},"HP",olc::WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
DrawStringDecal(hpTextPos,"HP",olc::BLACK);
|
||||
DrawRollingCounter(hpTextPos,member->HP,player_rollhp_display[i],player_rollhp_counter[i]);
|
||||
const olc::vi2d mpTextPos = {box.x+5,hpTextPos.y+17};
|
||||
for (int x=-1;x<=1;x++) {
|
||||
for (int y=-1;y<=1;y++) {
|
||||
if (x!=0&&y!=0) {
|
||||
DrawStringDecal({(float)(mpTextPos.x+x),(float)(mpTextPos.y+y)},"PP",olc::WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
DrawStringDecal(mpTextPos,"PP",olc::BLACK);
|
||||
DrawRollingCounter(mpTextPos,member->PP,player_rollpp_display[i],player_rollpp_counter[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (messageBoxVisible) {
|
||||
SetDrawTarget(layer::INTERFACE);
|
||||
DrawDialogBox({1,1},{WIDTH/2,HEIGHT/4},Pixel(70, 33, 105,128),Pixel(62, 54, 69,128),Pixel(185, 148, 255,128));
|
||||
@ -1243,6 +1362,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
OBJECTS.clear();
|
||||
for (int i=0;i<4;i++) {
|
||||
PARTY_MEMBER_OBJ[i]=nullptr;
|
||||
PARTY_MEMBER_ID[i]=0;
|
||||
}
|
||||
std::string data;
|
||||
while (f.good()) {
|
||||
@ -1461,6 +1581,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
void SetupAnimations() {
|
||||
CreateSprite("terrainmap.png");
|
||||
CreateSprite("additionalFont.png");
|
||||
CreateSprite("rollingcounter.png");
|
||||
}
|
||||
|
||||
void SetupObjectInfo() {
|
||||
@ -1701,9 +1822,22 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
std::vector<Object*>::const_iterator it = OBJECTS.begin();
|
||||
if (obj->id==PLAYER&&!obj->temp) {
|
||||
PARTY_MEMBER_OBJ[0]=obj;
|
||||
PARTY_MEMBER_ID[0]=0;
|
||||
PARTY_MEMBER_OBJ[0]->name="PLAYER";
|
||||
for (int i=toint(Flag::HAS_MAIN)+1;i<=toint(Flag::HAS_POO);i++) {
|
||||
if (GetGameFlag(i)) {
|
||||
PARTY_MEMBER_OBJ[PARTY_MEMBER_COUNT++]=AddObjectToWorld(CreateObject(toint(PLAYER)+i-toint(Flag::HAS_MAIN),PARTY_MEMBER_OBJ[0]->GetPos()));
|
||||
PARTY_MEMBER_ID[PARTY_MEMBER_COUNT]=toint(PLAYER)+i-toint(Flag::HAS_MAIN);
|
||||
PARTY_MEMBER_OBJ[PARTY_MEMBER_COUNT]=AddObjectToWorld(CreateObject(toint(PLAYER)+i-toint(Flag::HAS_MAIN),PARTY_MEMBER_OBJ[0]->GetPos()));
|
||||
switch (toint(PLAYER)+i-toint(Flag::HAS_MAIN)) {
|
||||
case 0:{PARTY_MEMBER_OBJ[PARTY_MEMBER_COUNT]->name="PLAYER";}break;
|
||||
case 1:{PARTY_MEMBER_OBJ[PARTY_MEMBER_COUNT]->name="NESS";}break;
|
||||
case 2:{PARTY_MEMBER_OBJ[PARTY_MEMBER_COUNT]->name="PAULA";}break;
|
||||
case 3:{PARTY_MEMBER_OBJ[PARTY_MEMBER_COUNT]->name="JEFF";}break;
|
||||
case 4:{PARTY_MEMBER_OBJ[PARTY_MEMBER_COUNT]->name="ANNA";}break;
|
||||
case 5:{PARTY_MEMBER_OBJ[PARTY_MEMBER_COUNT]->name="KING";}break;
|
||||
case 6:{PARTY_MEMBER_OBJ[PARTY_MEMBER_COUNT]->name="POO";}break;
|
||||
}
|
||||
PARTY_MEMBER_COUNT++;
|
||||
if (PARTY_MEMBER_COUNT==4) {
|
||||
break;
|
||||
}
|
||||
@ -1945,6 +2079,42 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
PARTY_MEMBER_OBJ[i]->SetPos(partyTrail[PARTY_TRAIL_LENGTH*((double)i/4)]);
|
||||
}
|
||||
}
|
||||
|
||||
void drawBox(const olc::vi2d &pos, const olc::vi2d &size, olc::Pixel p = olc::WHITE, olc::Pixel p2 = olc::DARK_GREY, olc::Pixel p3 = olc::VERY_DARK_GREY) {
|
||||
FillRectDecal({(float)(pos.x+3),(float)(pos.y+3)},{(float)(size.x-5),(float)(size.y-5)},p);
|
||||
DrawRect({pos.x,pos.y},size,p2);
|
||||
DrawRect({pos.x+2,pos.y+2},{size.x-4,size.y-4},p3);
|
||||
DrawRect({pos.x+1,pos.y+1},{size.x-2,size.y-2},p);
|
||||
Draw({pos.x,pos.y},olc::BLACK);
|
||||
Draw({pos.x+size.x,pos.y+size.y},olc::BLACK);
|
||||
Draw({pos.x+size.x,pos.y},olc::BLACK);
|
||||
Draw({pos.x,pos.y+size.y},olc::BLACK);
|
||||
}
|
||||
|
||||
void drawCheckerboardBox(const olc::vi2d &pos, const olc::vi2d &size, olc::Pixel p = olc::WHITE, olc::Pixel alternatingCol = olc::WHITE, const olc::vi2d &checkerboardSize = {3,3}, olc::Pixel p2 = olc::DARK_GREY, olc::Pixel p3 = olc::VERY_DARK_GREY) {
|
||||
drawBox(pos,size,p,p2,p3);
|
||||
for (int x=3;x<size.x;x+=checkerboardSize.x*2) {
|
||||
for (int y=3;y<size.y;y+=checkerboardSize.y*2) {
|
||||
if (x+checkerboardSize.x<size.x&&y+checkerboardSize.y<size.y) {
|
||||
FillRectDecal({(float)(x+pos.x),(float)(y+pos.y)},{(float)checkerboardSize.x,(float)checkerboardSize.y},alternatingCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawRollingCounter(const olc::vi2d &pos,int val,int*rollcounter,int*rolloffset) {
|
||||
FillRectDecal({(float)(pos.x+20),(float)(pos.y-3)},{30,13},olc::DARK_GREY);
|
||||
FillRectDecal({(float)(pos.x+21),(float)(pos.y-2)},{28,11},olc::GREY);
|
||||
DrawLineDecal({(float)(pos.x+30),(float)(pos.y-3)},{(float)(pos.x+30),(float)(pos.y+10)},olc::DARK_GREY);
|
||||
DrawLineDecal({(float)(pos.x+40),(float)(pos.y-3)},{(float)(pos.x+40),(float)(pos.y+10)},olc::DARK_GREY);
|
||||
DrawPartialDecal({(float)(pos.x+22),(float)(pos.y-1)},{7,9},SPRITES["rollingcounter.png"],{0,(float)(rollcounter[2]*13+rolloffset[2])},{7,9});
|
||||
DrawPartialDecal({(float)(pos.x+31),(float)(pos.y-1)},{7,9},SPRITES["rollingcounter.png"],{0,(float)(rollcounter[1]*13+rolloffset[1])},{7,9});
|
||||
DrawPartialDecal({(float)(pos.x+41),(float)(pos.y-1)},{7,9},SPRITES["rollingcounter.png"],{0,(float)(rollcounter[0]*13+rolloffset[0])},{7,9});
|
||||
}
|
||||
|
||||
void ResetBattleState() {
|
||||
CAMERA_WAIT_TIMER=0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user