generated from sigonasr2/CPlusPlusProjectTemplate
Party member system setup
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
29284803f2
commit
dbc07b4eac
Binary file not shown.
@ -48,38 +48,38 @@
|
||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
OBJECT256.000000;128.000000;2
|
||||
OBJECT224.000000;128.000000;2
|
||||
OBJECT160.000000;128.000000;2
|
||||
OBJECT192.000000;128.000000;2
|
||||
OBJECT288.000000;128.000000;2
|
||||
OBJECT313.000000;131.000000;4
|
||||
OBJECT192.000000;160.000000;2
|
||||
OBJECT160.000000;160.000000;2
|
||||
OBJECT256.000000;160.000000;2
|
||||
OBJECT224.000000;160.000000;1
|
||||
OBJECT288.000000;160.000000;1
|
||||
OBJECT313.000000;136.000000;5
|
||||
OBJECT313.000000;141.000000;6
|
||||
OBJECT256.000000;128.000000;8
|
||||
OBJECT224.000000;128.000000;8
|
||||
OBJECT160.000000;128.000000;8
|
||||
OBJECT192.000000;128.000000;8
|
||||
OBJECT288.000000;128.000000;8
|
||||
OBJECT313.000000;131.000000;10
|
||||
OBJECT192.000000;160.000000;8
|
||||
OBJECT160.000000;160.000000;8
|
||||
OBJECT256.000000;160.000000;8
|
||||
OBJECT224.000000;160.000000;7
|
||||
OBJECT288.000000;160.000000;7
|
||||
OBJECT313.000000;136.000000;11
|
||||
OBJECT313.000000;141.000000;12
|
||||
OBJECT313.000000;151.000000;8
|
||||
OBJECT288.000000;160.000000;3
|
||||
OBJECT224.000000;160.000000;3
|
||||
OBJECT160.000000;192.000000;2
|
||||
OBJECT256.000000;192.000000;2
|
||||
OBJECT288.000000;192.000000;2
|
||||
OBJECT224.000000;192.000000;2
|
||||
OBJECT192.000000;192.000000;1
|
||||
OBJECT192.000000;224.000000;2
|
||||
OBJECT160.000000;224.000000;2
|
||||
OBJECT288.000000;224.000000;2
|
||||
OBJECT224.000000;224.000000;2
|
||||
OBJECT256.000000;224.000000;1
|
||||
OBJECT288.000000;160.000000;9
|
||||
OBJECT224.000000;160.000000;9
|
||||
OBJECT160.000000;192.000000;8
|
||||
OBJECT256.000000;192.000000;8
|
||||
OBJECT288.000000;192.000000;8
|
||||
OBJECT224.000000;192.000000;8
|
||||
OBJECT192.000000;192.000000;7
|
||||
OBJECT192.000000;224.000000;8
|
||||
OBJECT160.000000;224.000000;8
|
||||
OBJECT288.000000;224.000000;8
|
||||
OBJECT224.000000;224.000000;8
|
||||
OBJECT256.000000;224.000000;7
|
||||
OBJECT212.000000;228.000000;0
|
||||
OBJECT288.000000;256.000000;2
|
||||
OBJECT256.000000;256.000000;2
|
||||
OBJECT224.000000;256.000000;2
|
||||
OBJECT192.000000;256.000000;2
|
||||
OBJECT160.000000;256.000000;2
|
||||
OBJECT288.000000;256.000000;8
|
||||
OBJECT256.000000;256.000000;8
|
||||
OBJECT224.000000;256.000000;8
|
||||
OBJECT192.000000;256.000000;8
|
||||
OBJECT160.000000;256.000000;8
|
||||
ENCOUNTER64;64;90;0
|
||||
ENCOUNTER64;256;90;1
|
||||
ENCOUNTER64;512;90;2
|
7
flags.h
7
flags.h
@ -3,6 +3,13 @@ enum class Flag:int{
|
||||
TEST_FLAG1,
|
||||
TEST_FLAG2,
|
||||
TEST_FLAG3,
|
||||
HAS_MAIN,
|
||||
HAS_NESS,
|
||||
HAS_PAULA,
|
||||
HAS_JEFF,
|
||||
HAS_ANNA,
|
||||
HAS_KING,
|
||||
HAS_POO,
|
||||
};
|
||||
|
||||
|
||||
|
90
main.cpp
90
main.cpp
@ -18,6 +18,7 @@
|
||||
#define TILEMAP_SIZE_Y 512
|
||||
#define TILEMAP_EDITOR_DRAW_MULT 0.4375
|
||||
#define TILEMAP_EDITOR_TILESIZE (32*TILEMAP_EDITOR_DRAW_MULT)
|
||||
#define PARTY_TRAIL_LENGTH 48
|
||||
|
||||
#define AddAsyncCutsceneAction(AsyncClass) \
|
||||
if (!((AsyncClass*)CurrentCutscene->GetAction())->InQueue()) { \
|
||||
@ -128,26 +129,26 @@ class Object{
|
||||
void SetPos(vd2d pos) {
|
||||
Move(pos-this->pos);
|
||||
}
|
||||
void SmoothMove(vd2d move) {
|
||||
bool SmoothMove(vd2d move) {
|
||||
const int wiggleRoom=5;
|
||||
vd2d originPos = {pos.x+originPoint.x,pos.y-1+originPoint.y};
|
||||
if (!Collision(originPos+move)) {
|
||||
Move(move);
|
||||
return;
|
||||
return true;
|
||||
} else
|
||||
if (move.x>0) {
|
||||
for (int i=0;i<wiggleRoom;i++) { //Search Up.
|
||||
if (!Collision({originPos.x+move.x,originPos.y-i})) {
|
||||
//There is potentially to move up-right here, so we will do so.
|
||||
Move({0,-1});
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (int i=0;i<wiggleRoom;i++) { //Search Down.
|
||||
if (!Collision({originPos.x+move.x,originPos.y+i})) {
|
||||
//There is potentially to move down-right here, so we will do so.
|
||||
Move({0,1});
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else
|
||||
@ -156,14 +157,14 @@ class Object{
|
||||
if (!Collision({originPos.x+move.x,originPos.y-i})) {
|
||||
//There is potentially to move up-left here, so we will do so.
|
||||
Move({0,-1});
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (int i=0;i<wiggleRoom;i++) { //Search Down.
|
||||
if (!Collision({originPos.x+move.x,originPos.y+i})) {
|
||||
//There is potentially to move down-left here, so we will do so.
|
||||
Move({0,1});
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else
|
||||
@ -172,14 +173,14 @@ class Object{
|
||||
if (!Collision({originPos.x-i,originPos.y+move.y})) {
|
||||
//There is potentially to move down-left here, so we will do so.
|
||||
Move({-1,0});
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (int i=0;i<wiggleRoom;i++) { //Search Right.
|
||||
if (!Collision({originPos.x+i,originPos.y+move.y})) {
|
||||
//There is potentially to move down-right here, so we will do so.
|
||||
Move({1,0});
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else
|
||||
@ -188,17 +189,18 @@ class Object{
|
||||
if (!Collision({originPos.x-i,originPos.y+move.y})) {
|
||||
//There is potentially to move up-left here, so we will do so.
|
||||
Move({-1,0});
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (int i=0;i<wiggleRoom;i++) { //Search Right.
|
||||
if (!Collision({originPos.x+i,originPos.y+move.y})) {
|
||||
//There is potentially to move up-right here, so we will do so.
|
||||
Move({1,0});
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@ -256,6 +258,11 @@ class Entity{
|
||||
bool dumb=false;
|
||||
Object* obj;
|
||||
std::vector<Battle::Move*> moveSet;
|
||||
//Used for initializing players.
|
||||
Entity(int HP,int maxHP,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,baseAtk,resistances,speed,moveSet,damageReduction,smart,dumb);
|
||||
}
|
||||
//Use this for initializing enemies as it lets you specify an object.
|
||||
Entity(Object*obj,int HP,int maxHP,int baseAtk,std::array<int,4>resistances,int speed,std::vector<Battle::Move*>moveSet,int damageReduction=0,bool smart=false,bool dumb=false) {
|
||||
this->obj=obj;
|
||||
this->HP=this->targetHP=HP;
|
||||
@ -326,7 +333,7 @@ public:
|
||||
int SELECTED_OBJ_ID = PLAYER;
|
||||
int OBJ_DISPLAY_OFFSET = 0;
|
||||
bool GAME_FLAGS[128]={};
|
||||
Object* PLAYER_OBJ;
|
||||
std::array<Object*,4> PARTY_MEMBER_OBJ;
|
||||
bool messageBoxVisible=false;
|
||||
std::string messageBoxText="";
|
||||
std::string targetText="";
|
||||
@ -343,6 +350,8 @@ public:
|
||||
double CUTSCENE_FADE_VALUE=0;
|
||||
std::vector<CutsceneAction*>CUTSCENE_QUEUE;
|
||||
std::map<BattleMoveName,Battle::Move*>MOVELIST;
|
||||
std::array<vd2d,PARTY_TRAIL_LENGTH> partyTrail={vd2d{0,0}};
|
||||
int PARTY_MEMBER_COUNT = 1;
|
||||
|
||||
|
||||
bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things.
|
||||
@ -377,6 +386,10 @@ public:
|
||||
SetGameFlag(Flag::TEST_FLAG1,false);
|
||||
SetGameFlag(Flag::TEST_FLAG2,false);
|
||||
SetGameFlag(Flag::TEST_FLAG3,false);
|
||||
SetGameFlag(Flag::HAS_MAIN,true);
|
||||
SetGameFlag(Flag::HAS_NESS,true);
|
||||
SetGameFlag(Flag::HAS_PAULA,true);
|
||||
SetGameFlag(Flag::HAS_ANNA,true);
|
||||
|
||||
additionalChars[0x391]={0,0};
|
||||
additionalChars[0x392]={8,0};
|
||||
@ -613,16 +626,24 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
if (PlayerCanMove()) {
|
||||
if (GetKey(I).bHeld) {
|
||||
PLAYER_OBJ->SmoothMove({0,-1});
|
||||
if (PARTY_MEMBER_OBJ[0]->SmoothMove({0,-1})) {
|
||||
UpdatePlayerTrail({0,-1});
|
||||
}
|
||||
}
|
||||
if (GetKey(K).bHeld) {
|
||||
PLAYER_OBJ->SmoothMove({0,1});
|
||||
if (PARTY_MEMBER_OBJ[0]->SmoothMove({0,1})) {
|
||||
UpdatePlayerTrail({0,1});
|
||||
}
|
||||
}
|
||||
if (GetKey(J).bHeld) {
|
||||
PLAYER_OBJ->SmoothMove({-1,0});
|
||||
if (PARTY_MEMBER_OBJ[0]->SmoothMove({-1,0})) {
|
||||
UpdatePlayerTrail({-1,0});
|
||||
}
|
||||
}
|
||||
if (GetKey(L).bHeld) {
|
||||
PLAYER_OBJ->SmoothMove({1,0});
|
||||
if (PARTY_MEMBER_OBJ[0]->SmoothMove({1,0})) {
|
||||
UpdatePlayerTrail({1,0});
|
||||
}
|
||||
}
|
||||
}
|
||||
int selectedTileX=(GetMouseX()+cameraPos.x)/32;
|
||||
@ -989,7 +1010,9 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
delete OBJECTS[i];
|
||||
}
|
||||
OBJECTS.clear();
|
||||
PLAYER_OBJ=nullptr;
|
||||
for (int i=0;i<4;i++) {
|
||||
PARTY_MEMBER_OBJ[i]=nullptr;
|
||||
}
|
||||
std::string data;
|
||||
while (f.good()) {
|
||||
f>>data;
|
||||
@ -1189,6 +1212,12 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
|
||||
void SetupObjectInfo() {
|
||||
CreateObjectInfo(PLAYER,"player",{0,0},"player.png",32,{1,1},WHITE);
|
||||
CreateObjectInfo(NESS,"Ness",{0,0},"player.png",32,{1,1},YELLOW);
|
||||
CreateObjectInfo(PAULA,"Paula",{0,0},"player.png",32,{1,1},MAGENTA);
|
||||
CreateObjectInfo(JEFF,"Jeff",{0,0},"player.png",32,{1,1},DARK_GREEN);
|
||||
CreateObjectInfo(ANNA,"Anna",{0,0},"player.png",32,{1,1},DARK_MAGENTA);
|
||||
CreateObjectInfo(KING,"King",{0,0},"player.png",32,{1,1},GREY);
|
||||
CreateObjectInfo(POO,"Poo",{0,0},"player.png",32,{1,1},DARK_GREY);
|
||||
CreateObjectInfo(NPC1,"npc1",{0,0},"player.png",32,{1,1},RED,Flag::NONE,Flag::NONE,60);
|
||||
CreateObjectInfo(NPC2,"npc2",{0,0},"player.png",32,{1,1},GREEN,Flag::NONE,Flag::NONE,2);
|
||||
CreateObjectInfo(NPC3,"npc3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
||||
@ -1351,10 +1380,18 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
CreateObjectInfo(NPC19_8,"npc20_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
||||
}
|
||||
|
||||
void AddObjectToWorld(Object*obj) {
|
||||
Object* AddObjectToWorld(Object*obj) {
|
||||
std::vector<Object*>::const_iterator it = OBJECTS.begin();
|
||||
if (obj->id==PLAYER&&!obj->temp) {
|
||||
PLAYER_OBJ=obj;
|
||||
PARTY_MEMBER_OBJ[0]=obj;
|
||||
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()));
|
||||
if (PARTY_MEMBER_COUNT==4) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bool inserted=false;
|
||||
for (int i=0;i<OBJECTS.size();i++) {
|
||||
@ -1382,6 +1419,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
assert(i==OBJECTS[i]->objArrElement);
|
||||
}
|
||||
return obj;
|
||||
//printf("\n");
|
||||
}
|
||||
|
||||
@ -1427,7 +1465,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
|
||||
bool PlayerCanMove(){
|
||||
return !messageBoxVisible&&PLAYER_OBJ!=nullptr;
|
||||
return !messageBoxVisible&&PARTY_MEMBER_OBJ[0]!=nullptr;
|
||||
}
|
||||
|
||||
void DisplayMessageBox(std::string targetText) {
|
||||
@ -1549,6 +1587,10 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
GAME_FLAGS[toint(flag)]=val;
|
||||
}
|
||||
|
||||
bool GetGameFlag(int flag) {
|
||||
return GAME_FLAGS[flag];
|
||||
}
|
||||
|
||||
bool GetGameFlag(Flag flag) {
|
||||
return GAME_FLAGS[toint(flag)];
|
||||
}
|
||||
@ -1635,6 +1677,16 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
AddObjectToWorld(data->objs[i]->obj);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdatePlayerTrail(vd2d newMovement) {
|
||||
for (int i=PARTY_TRAIL_LENGTH-1;i>0;i--) {
|
||||
partyTrail[i]=partyTrail[i-1];
|
||||
}
|
||||
partyTrail[0]=PARTY_MEMBER_OBJ[0]->GetPos()-newMovement;
|
||||
for (int i=1;i<PARTY_MEMBER_COUNT;i++) {
|
||||
PARTY_MEMBER_OBJ[i]->SetPos(partyTrail[PARTY_TRAIL_LENGTH*((double)i/4)]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,5 +1,11 @@
|
||||
enum Reference{
|
||||
PLAYER,
|
||||
NESS,
|
||||
PAULA,
|
||||
JEFF,
|
||||
ANNA,
|
||||
KING,
|
||||
POO,
|
||||
NPC1,
|
||||
NPC2,
|
||||
NPC3,
|
||||
|
Loading…
x
Reference in New Issue
Block a user