diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 9c951cd..12f03c6 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/main.cpp b/main.cpp index c1ac46e..023af6a 100644 --- a/main.cpp +++ b/main.cpp @@ -448,6 +448,15 @@ class Map{ } }; +class DamageNumber{ + public: + int damage; //If it's negative then it's a healing number. + vd2d pos; + int timer; + DamageNumber(int damage,vd2d pos,int timer=90) + :damage(damage),pos(pos),timer(timer){} +}; + class SeasonI : public PixelGameEngine { public: @@ -535,6 +544,7 @@ public: std::map OBJ_INFO; std::vector PARTICLES; + std::vector DAMAGE_NUMBERS; Effect*CURRENT_EFFECT=nullptr; @@ -661,13 +671,25 @@ goes on a very long time, I hope you can understand this is only for testing pur void updateGame(){ frameCount++; - for (auto&obj:OBJECTS) { + for (auto obj:OBJECTS) { if (obj->animationSpd!=0&&obj->frameCount++>obj->animationSpd) { obj->frameCount=0; obj->frameIndex++; } } + for (int i=0;itimer>0) { + numb->pos.y-=(numb->timer/180.0F); + numb->timer--; + } else { + delete numb; + DAMAGE_NUMBERS.erase(DAMAGE_NUMBERS.begin()+i--); + continue; + } + } + for (int i=0;iupdate()) { delete PARTICLES[i]; @@ -1589,6 +1611,13 @@ goes on a very long time, I hope you can understand this is only for testing pur } } } + for (auto numb:DAMAGE_NUMBERS) { + vd2d textSize = GetTextSizeProp((numb->damage>=0)?"-"+std::to_string(numb->damage):"+"+std::to_string(-numb->damage)); + DrawStringPropDecal(numb->pos-cameraPos-textSize/2,(numb->damage>=0)?"-"+std::to_string(numb->damage):"+"+std::to_string(-numb->damage),(numb->damage>=0)?RED:GREEN,{1,2}); + vd2d shadowOffset={1,1}; + DrawStringPropDecal(numb->pos+shadowOffset-cameraPos-textSize/2,(numb->damage>=0)?"-"+std::to_string(numb->damage):"+"+std::to_string(-numb->damage),(numb->damage>=0)?RED:GREEN,{1,2}); + DrawStringPropDecal(numb->pos-cameraPos-textSize/2,(numb->damage>=0)?"-"+std::to_string(numb->damage):"+"+std::to_string(-numb->damage),Pixel(255,255,255,sin((M_PI*frameCount)/30)*128),{1,2}); + } 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)); @@ -2897,7 +2926,7 @@ goes on a very long time, I hope you can understand this is only for testing pur StartEffect(eff); } } - if (CURRENT_EFFECT==nullptr&&BATTLE_ANIMATION_TIMER==90||CURRENT_EFFECT!=nullptr&&BATTLE_ANIMATION_TIMER>CURRENT_EFFECT->maxLifeTime-30) { + if (CURRENT_EFFECT==nullptr&&BATTLE_ANIMATION_TIMER==90||CURRENT_EFFECT!=nullptr&&BATTLE_ANIMATION_TIMER>CURRENT_EFFECT->maxLifeTime) { if (CURRENT_TURN<0) { if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->friendly) { if (PARTY_MEMBER_STATS[-PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget-1]->GetHP()>0) { @@ -2905,8 +2934,13 @@ goes on a very long time, I hope you can understand this is only for testing pur ((PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->randomDmg>0)?rand()%PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->randomDmg:0) +PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->baseAtk; for (auto&ent:GetEntitiesInRange(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) { - std::cout << PARTY_MEMBER_OBJ[-CURRENT_TURN-1]->name << " uses " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->name << " " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->grade << " on " << ent->obj->name << " recovering " << healAmt << " health.\n"; - ent->AddHP(healAmt); + if (ent->GetHP()>0) { + std::cout << PARTY_MEMBER_OBJ[-CURRENT_TURN-1]->name << " uses " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->name << " " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->grade << " on " << ent->obj->name << " recovering " << healAmt << " health.\n"; + ent->AddHP(healAmt); + int memberID = getMemberIDComparingObject(ent->obj); + vi2d box = {(128-32*PARTY_MEMBER_COUNT)+memberID*64+29,170}; + DAMAGE_NUMBERS.push_back(new DamageNumber(-healAmt,box+cameraPos)); + } } } else { std::cout << PARTY_MEMBER_OBJ[-CURRENT_TURN-1]->name << " uses " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->name << " " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->grade << " on " << PARTY_MEMBER_OBJ[-PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget-1]->name << " but it failed.\n"; @@ -2918,11 +2952,14 @@ goes on a very long time, I hope you can understand this is only for testing pur +PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->baseAtk; //Enemies have their health directly set. for (auto&ent:GetEntitiesInRange(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedTarget,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove)) { - std::cout << PARTY_MEMBER_OBJ[-CURRENT_TURN-1]->name << " uses " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->name << " " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->grade << " on " << ent->obj->name << " dealing " << dmgAmt << " health.\n"; - ent->_SetDirectHP(ent->GetHP()-dmgAmt); - ent->obj->blinkFrames=35; - if (ent->GetHP()<=0) { - ent->obj->dead=true; + if (ent->GetHP()>0) { + std::cout << PARTY_MEMBER_OBJ[-CURRENT_TURN-1]->name << " uses " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->name << " " << PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove->grade << " on " << ent->obj->name << " dealing " << dmgAmt << " health.\n"; + ent->_SetDirectHP(ent->GetHP()-dmgAmt); + ent->obj->blinkFrames=35; + if (ent->GetHP()<=0) { + ent->obj->dead=true; + } + DAMAGE_NUMBERS.push_back(new DamageNumber(dmgAmt,ent->obj->GetPosWithOrigin())); } } } else { @@ -2936,8 +2973,11 @@ goes on a very long time, I hope you can understand this is only for testing pur ((rand()%BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->randomDmg>0)?rand()%BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->randomDmg:0) +BATTLE_ENCOUNTER->objs[CURRENT_TURN]->baseAtk; for (auto&ent:GetEntitiesInRange(BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget,BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove)) { - std::cout << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->obj->name << " uses " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->name << " " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->grade << " on " << ent->obj->name << " recovering " << healAmt << " health.\n"; - ent->AddHP(healAmt); + if (ent->GetHP()>0) { + std::cout << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->obj->name << " uses " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->name << " " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->grade << " on " << ent->obj->name << " recovering " << healAmt << " health.\n"; + ent->AddHP(healAmt); + DAMAGE_NUMBERS.push_back(new DamageNumber(-healAmt,ent->obj->GetPosWithOrigin())); + } } } else { std::cout << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->obj->name << " uses " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->name << " " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->grade << " on " << BATTLE_ENCOUNTER->objs[BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget]->obj->name << " but it failed.\n"; @@ -2948,12 +2988,17 @@ goes on a very long time, I hope you can understand this is only for testing pur ((rand()%BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->randomDmg>0)?rand()%BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->randomDmg:0) +BATTLE_ENCOUNTER->objs[CURRENT_TURN]->baseAtk; for (auto&ent:GetEntitiesInRange(BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget,BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove)) { - std::cout << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->obj->name << " uses " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->name << " " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->grade << " on " << ent->obj->name << " dealing " << dmgAmt << " health.\n"; - ent->SubtractHP(dmgAmt); - if (ent->GetTargetHP()<0) { - BATTLE_HIT_SCREENSHAKE=75; - } else { - BATTLE_HIT_SCREENSHAKE=25; + if (ent->GetHP()>0) { + std::cout << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->obj->name << " uses " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->name << " " << BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove->grade << " on " << ent->obj->name << " dealing " << dmgAmt << " health.\n"; + ent->SubtractHP(dmgAmt); + if (ent->GetTargetHP()<0) { + BATTLE_HIT_SCREENSHAKE=75; + } else { + BATTLE_HIT_SCREENSHAKE=25; + } + int memberID = getMemberIDComparingObject(ent->obj); + vi2d box = {(128-32*PARTY_MEMBER_COUNT)+memberID*64+29,170}; + DAMAGE_NUMBERS.push_back(new DamageNumber(dmgAmt,box+cameraPos)); } } } else { @@ -2962,7 +3007,7 @@ goes on a very long time, I hope you can understand this is only for testing pur } } } else - if (CURRENT_EFFECT==nullptr&&BATTLE_ANIMATION_TIMER>120||CURRENT_EFFECT!=nullptr&&BATTLE_ANIMATION_TIMER>CURRENT_EFFECT->maxLifeTime) { + if (CURRENT_EFFECT==nullptr&&BATTLE_ANIMATION_TIMER>120||CURRENT_EFFECT!=nullptr&&BATTLE_ANIMATION_TIMER>CURRENT_EFFECT->maxLifeTime+30) { //Turn's done! if (CURRENT_TURN<0) { PARTY_MEMBER_STATS[PARTY_MEMBER_ID[-CURRENT_TURN-1]]->selectedMove=nullptr; @@ -3202,6 +3247,17 @@ goes on a very long time, I hope you can understand this is only for testing pur CURRENT_EFFECT=eff; eff->create(PARTICLES); } + + int getMemberIDComparingObject(Object*obj) { + int memberID=0; + for (int i=0;iobj) { + memberID=i; + break; + } + } + return memberID; + } };