generated from sigonasr2/CPlusPlusProjectTemplate
Battle menu command display. List of battle powers created.
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
5252d1ad70
commit
9577d482be
Binary file not shown.
BIN
assets/cursor.png
Normal file
BIN
assets/cursor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 570 B |
237
main.cpp
237
main.cpp
@ -26,6 +26,12 @@
|
||||
#define ㅍ
|
||||
#define 아
|
||||
|
||||
#define α 0x391
|
||||
#define β 0x392
|
||||
#define γ 0x3b3
|
||||
#define Ω 0x3a3
|
||||
#define Σ 0x3a9
|
||||
|
||||
#define AddAsyncCutsceneAction(AsyncClass) \
|
||||
if (!((AsyncClass*)CurrentCutscene->GetAction())->InQueue()) { \
|
||||
CUTSCENE_QUEUE.push_back(CurrentCutscene->GetAction()); \
|
||||
@ -38,6 +44,14 @@ std::vector<Object*> OBJECTS;
|
||||
|
||||
using namespace olc;
|
||||
|
||||
enum{
|
||||
ALPHA=α,
|
||||
BETA=β,
|
||||
GAMMA=γ,
|
||||
OMEGA=Ω,
|
||||
SIGMA=Σ,
|
||||
};
|
||||
|
||||
namespace layer{
|
||||
enum layer{
|
||||
INTERFACE, //Interface items should be on this layer. On top of everything.
|
||||
@ -245,6 +259,26 @@ enum class BattleMoveName{
|
||||
TESTMOVE1,
|
||||
TESTMOVE2,
|
||||
TESTMOVE3,
|
||||
HAILSTORM_A,
|
||||
HAILSTORM_B,
|
||||
HAILSTORM_G,
|
||||
HAILSTORM_O,
|
||||
HURRICANE_A,
|
||||
HURRICANE_B,
|
||||
HURRICANE_G,
|
||||
HURRICANE_O,
|
||||
METEORRAIN_A,
|
||||
METEORRAIN_B,
|
||||
METEORRAIN_G,
|
||||
METEORRAIN_O,
|
||||
PKFREEZE_A,
|
||||
PKFREEZE_B,
|
||||
PKFREEZE_G,
|
||||
PKFREEZE_O,
|
||||
PKSHIELD_A,
|
||||
PKSHIELD_B,
|
||||
PKSHIELD_O,
|
||||
PKSHIELD_S,
|
||||
};
|
||||
|
||||
namespace Battle{
|
||||
@ -257,8 +291,11 @@ namespace Battle{
|
||||
bool pctDamage; //Uses % damage for the base damage instead of flat damage.
|
||||
std::vector<std::pair<Property,int>> properties; //The int is used to determine the chance of something occurring.
|
||||
//Properties order is WET, DRY, COLD, HEAT
|
||||
int grade=0; //If the name of a move name match, then the grade helps sort it into the same category on menus.
|
||||
Move(std::string name,int baseDmg,int randomDmg,std::array<int,4>composition,bool pctDamage=false,std::vector<std::pair<Property,int>> properties={})
|
||||
:name(name),randomDmg(randomDmg),baseDmg(baseDmg),composition(composition),pctDamage(pctDamage),properties(properties){}
|
||||
:Move(name,0,baseDmg,randomDmg,composition,pctDamage,properties){};
|
||||
Move(std::string name,int grade,int baseDmg,int randomDmg,std::array<int,4>composition,bool pctDamage=false,std::vector<std::pair<Property,int>> properties={})
|
||||
:name(name),grade(grade),randomDmg(randomDmg),baseDmg(baseDmg),composition(composition),pctDamage(pctDamage),properties(properties){}
|
||||
};
|
||||
}
|
||||
|
||||
@ -395,6 +432,11 @@ public:
|
||||
int SELECTED_TEST_TARGET=0;
|
||||
int BATTLE_TARGET=-99; //Negative numbers for players and positive numbers for enemy targets.
|
||||
int CURRENT_TURN=-99; //Who's turn we are enacting.
|
||||
int BATTLE_SELECTION_CURSOR=0;
|
||||
int POWER_SELECTION_CURSOR=0;
|
||||
int TARGET_SELECTION_CURSOR=0;
|
||||
bool ANYKEYPRESSED=false;
|
||||
bool ACTIONKEYPRESSED=false;
|
||||
|
||||
|
||||
|
||||
@ -437,11 +479,11 @@ public:
|
||||
SetGameFlag(Flag::HAS_PAULA,true);
|
||||
SetGameFlag(Flag::HAS_ANNA,true);
|
||||
|
||||
additionalChars[0x391]={0,0};
|
||||
additionalChars[0x392]={8,0};
|
||||
additionalChars[0x3b3]={16,0};
|
||||
additionalChars[0x3a3]={24,0};
|
||||
additionalChars[0x3a9]={32,0};
|
||||
additionalChars[α]={0,0};
|
||||
additionalChars[β]={8,0};
|
||||
additionalChars[γ]={16,0};
|
||||
additionalChars[Ω]={24,0};
|
||||
additionalChars[Σ]={32,0};
|
||||
|
||||
MAP_ONETT=new Map("map0","map0_2","map0_3","map0_4","map0_5",SPRITES["terrainmap.png"]);
|
||||
|
||||
@ -514,7 +556,16 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
} else {
|
||||
messageBoxVisible=false;
|
||||
}
|
||||
} else {
|
||||
while (messageBoxMarker<messageBoxFinalText.length()) {
|
||||
AdvanceMessageBox();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ANYKEYPRESSED=true;
|
||||
if (!UpPressed()&&!DownPressed()&&!LeftPressed()&&!RightPressed()) {
|
||||
ACTIONKEYPRESSED=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -569,7 +620,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case BattleState::WAIT:{
|
||||
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
|
||||
Entity*member=PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]];
|
||||
@ -660,8 +711,9 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
for (int i=0;i<4;i++) {
|
||||
if (PARTY_MEMBER_STATS[PARTY_MEMBER_ID[i]]->atb>=1000) {
|
||||
printf("%s ready.\n",PARTY_MEMBER_OBJ[i]->name.c_str());
|
||||
CURRENT_TURN=-i;
|
||||
GAME_STATE=BattleState::SELECT_ACTION;
|
||||
CURRENT_TURN=-i-1;
|
||||
BATTLE_STATE=BattleState::SELECT_ACTION;
|
||||
BATTLE_SELECTION_CURSOR=0;
|
||||
done=true;
|
||||
break;
|
||||
} else {
|
||||
@ -673,7 +725,8 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
if (BATTLE_ENCOUNTER->objs[i]->atb>=1000) {
|
||||
printf("%s (%d) ready.\n",BATTLE_ENCOUNTER->objs[i]->obj->name.c_str(),i);
|
||||
CURRENT_TURN=i;
|
||||
GAME_STATE=BattleState::SELECT_ACTION;
|
||||
BATTLE_STATE=BattleState::SELECT_ACTION;
|
||||
BATTLE_SELECTION_CURSOR=0;
|
||||
done=true;
|
||||
break;
|
||||
} else {
|
||||
@ -964,43 +1017,47 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
|
||||
if (messageBoxVisible) {
|
||||
if (messageBoxLoad) {
|
||||
const int MESSAGE_BORDER_X=4;
|
||||
const int MESSAGE_BORDER_Y=4;
|
||||
bool charsWritten=false;
|
||||
while (messageBoxStartMarker+messageBoxStopMarker<targetText.length()&&GetTextSizeProp(messageBoxFinalText).y<HEIGHT/4-MESSAGE_BORDER_Y) {
|
||||
while (messageBoxStartMarker+messageBoxStopMarker<targetText.length()&&GetTextSizeProp(messageBoxFinalText).x<WIDTH/2-MESSAGE_BORDER_X) {
|
||||
if (!charsWritten&&targetText[messageBoxStopMarker+messageBoxStartMarker]!=' ') {
|
||||
messageBoxFinalText+=targetText[messageBoxStopMarker+++messageBoxStartMarker];
|
||||
charsWritten=true;
|
||||
} else
|
||||
if (charsWritten){
|
||||
messageBoxFinalText+=targetText[messageBoxStopMarker+++messageBoxStartMarker];
|
||||
} else {
|
||||
messageBoxStartMarker++;
|
||||
}
|
||||
}
|
||||
if (GetTextSizeProp(messageBoxFinalText).x>=WIDTH/2-MESSAGE_BORDER_X) {
|
||||
while (messageBoxFinalText[messageBoxStopMarker]!=' ') {
|
||||
messageBoxStopMarker--;
|
||||
};
|
||||
messageBoxFinalText.erase(messageBoxFinalText.begin()+messageBoxStopMarker,messageBoxFinalText.end());
|
||||
messageBoxFinalText+='\n';
|
||||
charsWritten=false;
|
||||
}
|
||||
}
|
||||
messageBoxLoad=false;
|
||||
} else {
|
||||
if (messageBoxMarker<messageBoxFinalText.length()) {
|
||||
messageBoxText+=messageBoxFinalText[messageBoxMarker++];
|
||||
}
|
||||
}
|
||||
AdvanceMessageBox();
|
||||
}
|
||||
|
||||
//CAMERA UPDATES MUST BE LAST!!! COLLISIONS RELY ON THE GAME POSITION STATES REMAINING THE SAME!
|
||||
cameraUpdate();
|
||||
}
|
||||
|
||||
void AdvanceMessageBox() {
|
||||
if (messageBoxLoad) {
|
||||
const int MESSAGE_BORDER_X=4;
|
||||
const int MESSAGE_BORDER_Y=4;
|
||||
bool charsWritten=false;
|
||||
while (messageBoxStartMarker+messageBoxStopMarker<targetText.length()&&GetTextSizeProp(messageBoxFinalText).y<HEIGHT/4-MESSAGE_BORDER_Y) {
|
||||
while (messageBoxStartMarker+messageBoxStopMarker<targetText.length()&&GetTextSizeProp(messageBoxFinalText).x<WIDTH/2-MESSAGE_BORDER_X) {
|
||||
if (!charsWritten&&targetText[messageBoxStopMarker+messageBoxStartMarker]!=' ') {
|
||||
messageBoxFinalText+=targetText[messageBoxStopMarker+++messageBoxStartMarker];
|
||||
charsWritten=true;
|
||||
} else
|
||||
if (charsWritten){
|
||||
messageBoxFinalText+=targetText[messageBoxStopMarker+++messageBoxStartMarker];
|
||||
} else {
|
||||
messageBoxStartMarker++;
|
||||
}
|
||||
}
|
||||
if (GetTextSizeProp(messageBoxFinalText).x>=WIDTH/2-MESSAGE_BORDER_X) {
|
||||
while (messageBoxFinalText[messageBoxStopMarker]!=' ') {
|
||||
messageBoxStopMarker--;
|
||||
};
|
||||
messageBoxFinalText.erase(messageBoxFinalText.begin()+messageBoxStopMarker,messageBoxFinalText.end());
|
||||
messageBoxFinalText+='\n';
|
||||
charsWritten=false;
|
||||
}
|
||||
}
|
||||
messageBoxLoad=false;
|
||||
} else {
|
||||
if (messageBoxMarker<messageBoxFinalText.length()) {
|
||||
messageBoxText+=messageBoxFinalText[messageBoxMarker++];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//CAMERA UPDATES MUST BE LAST!!! COLLISIONS RELY ON THE GAME POSITION STATES REMAINING THE SAME!
|
||||
void cameraUpdate() {
|
||||
|
||||
@ -1039,22 +1096,50 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
ConsoleShow(F1,false);
|
||||
}
|
||||
|
||||
if (BATTLE_ENCOUNTER!=nullptr) {
|
||||
if (GetMouseWheel()>0) {
|
||||
SELECTED_TEST_TARGET=(SELECTED_TEST_TARGET+1)%4;
|
||||
printf("Selected Test Target:%d\n",SELECTED_TEST_TARGET);
|
||||
}
|
||||
if (GetKey(PGUP).bPressed) {
|
||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[SELECTED_TEST_TARGET]]->targetHP=std::clamp(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[SELECTED_TEST_TARGET]]->targetHP+10,0,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[SELECTED_TEST_TARGET]]->maxHP);
|
||||
}
|
||||
if (GetKey(PGDN).bPressed) {
|
||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[SELECTED_TEST_TARGET]]->targetHP=std::clamp(PARTY_MEMBER_STATS[PARTY_MEMBER_ID[SELECTED_TEST_TARGET]]->targetHP-10,0,PARTY_MEMBER_STATS[PARTY_MEMBER_ID[SELECTED_TEST_TARGET]]->maxHP);
|
||||
}
|
||||
if (GetKey(DEL).bPressed) {
|
||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[SELECTED_TEST_TARGET]]->targetHP=-50;
|
||||
}
|
||||
if (GetKey(END).bPressed) {
|
||||
PARTY_MEMBER_STATS[PARTY_MEMBER_ID[SELECTED_TEST_TARGET]]->targetHP=-350;
|
||||
if (BATTLE_ENCOUNTER!=nullptr&&!messageBoxVisible) {
|
||||
switch (BATTLE_STATE) {
|
||||
case BattleState::SELECT_ACTION:{
|
||||
if (CURRENT_TURN<0) {
|
||||
if (UpPressed()||DownPressed()) {
|
||||
if (BATTLE_SELECTION_CURSOR%2==0) {
|
||||
BATTLE_SELECTION_CURSOR++;
|
||||
} else {
|
||||
BATTLE_SELECTION_CURSOR--;
|
||||
}
|
||||
}
|
||||
if (RightPressed()) {
|
||||
BATTLE_SELECTION_CURSOR=(BATTLE_SELECTION_CURSOR+2)%6;
|
||||
}
|
||||
if (LeftPressed()) {
|
||||
BATTLE_SELECTION_CURSOR-=2;
|
||||
if (BATTLE_SELECTION_CURSOR<0) {
|
||||
BATTLE_SELECTION_CURSOR+=6;
|
||||
}
|
||||
}
|
||||
if (ACTIONKEYPRESSED) {
|
||||
switch (BATTLE_SELECTION_CURSOR) {
|
||||
case 0:{ //Power selected.
|
||||
DisplayMessageBox("Not implemented yet.");
|
||||
}break;
|
||||
case 1:{ //Attack selected.
|
||||
DisplayMessageBox("Not implemented yet.");
|
||||
}break;
|
||||
case 2:{ //Items selected.
|
||||
DisplayMessageBox("Not implemented yet.");
|
||||
}break;
|
||||
case 3:{ //Defend selected.
|
||||
DisplayMessageBox("Not implemented yet.");
|
||||
}break;
|
||||
case 4:{ //Move selected.
|
||||
DisplayMessageBox("Not implemented yet.");
|
||||
}break;
|
||||
case 5:{ //Run selected.
|
||||
DisplayMessageBox("Not implemented yet.");
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1175,6 +1260,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
}break;
|
||||
}
|
||||
ANYKEYPRESSED=ACTIONKEYPRESSED=false;
|
||||
}
|
||||
|
||||
void drawGame(){
|
||||
@ -1294,11 +1380,25 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
case BattleState::MOVE_CAMERA:{
|
||||
|
||||
}break;
|
||||
case BattleState::SELECT_ACTION:{
|
||||
SetDrawTarget(layer::HIGH);
|
||||
DrawDialogBox({1,1},{(int)(WIDTH*0.75),HEIGHT/6},Pixel(70, 33, 105,128),Pixel(62, 54, 69,128),Pixel(185, 148, 255,128));
|
||||
const std::string labels[6]={"Power","Attack","Item","Defend","Move","Run"};
|
||||
for (int i=0;i<6;i+=2) {
|
||||
DrawStringPropDecal({3+8+i/2*64,9},labels[i]);
|
||||
DrawStringPropDecal({3+8+i/2*64,23},labels[i+1]);
|
||||
}
|
||||
DrawDecal({BATTLE_SELECTION_CURSOR/2*64+3,9+((BATTLE_SELECTION_CURSOR%2==0)?0:14)},SPRITES["cursor.png"]);
|
||||
} //Break intentionally left out!
|
||||
default:{
|
||||
SetDrawTarget(layer::HIGH);
|
||||
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};
|
||||
olc::vi2d box = {(128-32*PARTY_MEMBER_COUNT)+i*64,160};
|
||||
if (CURRENT_TURN==-i-1) {
|
||||
box.y-=20;
|
||||
}
|
||||
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);
|
||||
DrawPartialDecal({(float)(box.x+4),(float)(box.y+5+8+2)},SPRITES["atbbar_back.png"],{0,0},{member->atb/1000.0*SPRITES["atbbar_back.png"]->sprite->width,SPRITES["atbbar_back.png"]->sprite->height});
|
||||
@ -1653,6 +1753,26 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
MOVELIST[BattleMoveName::TESTMOVE1]=new Battle::Move("Test Move 1",30,5,{0,0,0,0});
|
||||
MOVELIST[BattleMoveName::TESTMOVE2]=new Battle::Move("Test Move 2",40,10,{0,0,0,0});
|
||||
MOVELIST[BattleMoveName::TESTMOVE3]=new Battle::Move("Test Move 3",25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::HAILSTORM_A]=new Battle::Move("Hailstorm",ALPHA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::HAILSTORM_B]=new Battle::Move("Hailstorm",BETA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::HAILSTORM_G]=new Battle::Move("Hailstorm",GAMMA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::HAILSTORM_O]=new Battle::Move("Hailstorm",OMEGA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::HURRICANE_A]=new Battle::Move("Hurricane",ALPHA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::HURRICANE_B]=new Battle::Move("Hurricane",BETA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::HURRICANE_G]=new Battle::Move("Hurricane",GAMMA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::HURRICANE_O]=new Battle::Move("Hurricane",OMEGA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::METEORRAIN_A]=new Battle::Move("Meteor Rain",ALPHA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::METEORRAIN_B]=new Battle::Move("Meteor Rain",BETA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::METEORRAIN_G]=new Battle::Move("Meteor Rain",GAMMA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::METEORRAIN_O]=new Battle::Move("Meteor Rain",OMEGA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::PKFREEZE_A]=new Battle::Move("PK Freeze",ALPHA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::PKFREEZE_B]=new Battle::Move("PK Freeze",BETA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::PKFREEZE_G]=new Battle::Move("PK Freeze",GAMMA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::PKFREEZE_O]=new Battle::Move("PK Freeze",OMEGA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::PKSHIELD_A]=new Battle::Move("PK Shield",ALPHA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::PKSHIELD_B]=new Battle::Move("PK Shield",BETA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::PKSHIELD_O]=new Battle::Move("PK Shield",OMEGA,25,5,{0,0,20,0});
|
||||
MOVELIST[BattleMoveName::PKSHIELD_S]=new Battle::Move("PK Shield",SIGMA,25,5,{0,0,20,0});
|
||||
}
|
||||
|
||||
void SetupAnimations() {
|
||||
@ -1661,6 +1781,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
CreateSprite("rollingcounter.png");
|
||||
CreateSprite("atbbar_back.png");
|
||||
CreateSprite("atbbar_front.png");
|
||||
CreateSprite("cursor.png");
|
||||
}
|
||||
|
||||
void SetupObjectInfo() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user