diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 2b6b057..b6d212e 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/assets/maps/map0 b/assets/maps/map0 index 02d5432..0bed90f 100644 --- a/assets/maps/map0 +++ b/assets/maps/map0 @@ -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 \ No newline at end of file diff --git a/flags.h b/flags.h index ea2723d..4357a03 100644 --- a/flags.h +++ b/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, }; diff --git a/main.cpp b/main.cpp index 9b931d6..de86eab 100644 --- a/main.cpp +++ b/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 moveSet; + //Used for initializing players. + Entity(int HP,int maxHP,int baseAtk,std::arrayresistances,int speed,std::vectormoveSet,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::arrayresistances,int speed,std::vectormoveSet,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 PARTY_MEMBER_OBJ; bool messageBoxVisible=false; std::string messageBoxText=""; std::string targetText=""; @@ -343,6 +350,8 @@ public: double CUTSCENE_FADE_VALUE=0; std::vectorCUTSCENE_QUEUE; std::mapMOVELIST; + std::array 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::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;iobjArrElement); } + 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;iSetPos(partyTrail[PARTY_TRAIL_LENGTH*((double)i/4)]); + } + } }; diff --git a/references.h b/references.h index f751b66..f23fd93 100644 --- a/references.h +++ b/references.h @@ -1,5 +1,11 @@ enum Reference{ PLAYER, + NESS, + PAULA, + JEFF, + ANNA, + KING, + POO, NPC1, NPC2, NPC3,