diff --git a/C++ProjectTemplate b/C++ProjectTemplate index f82da99..72a112a 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/assets/maps/map0 b/assets/maps/map0 index 0c1ff22..d54c23c 100644 --- a/assets/maps/map0 +++ b/assets/maps/map0 @@ -53,26 +53,28 @@ OBJECT224.000000;128.000000;2 OBJECT160.000000;128.000000;2 OBJECT192.000000;128.000000;2 OBJECT288.000000;128.000000;2 -OBJECT212.000000;228.000000;0 +OBJECT313.000000;131.000000;4 OBJECT192.000000;160.000000;2 OBJECT160.000000;160.000000;2 -OBJECT192.000000;192.000000;2 -OBJECT160.000000;192.000000;2 -OBJECT192.000000;224.000000;2 -OBJECT160.000000;224.000000;2 -OBJECT313.000000;131.000000;4 -OBJECT288.000000;160.000000;3 -OBJECT224.000000;160.000000;3 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 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 -OBJECT256.000000;224.000000;2 OBJECT224.000000;224.000000;2 +OBJECT256.000000;224.000000;1 +OBJECT212.000000;228.000000;0 OBJECT288.000000;256.000000;2 OBJECT256.000000;256.000000;2 OBJECT224.000000;256.000000;2 diff --git a/cutscene.h b/cutscene.h new file mode 100644 index 0000000..91622ce --- /dev/null +++ b/cutscene.h @@ -0,0 +1,115 @@ +#include "pixelGameEngine.h" +#include + +#define CAMERA_MOVESPD 5 + +using namespace olc; + +enum PriorityDirection{ + HORZ_FIRST, + VERT_FIRST, + BOTH +}; + +enum class ActionType{ + NONE, + PAN_CAMERA, + CREATE_OBJECTS, + CLEANUP +}; + +class CutsceneAction{ + public: + virtual ActionType GetActionType()=0; +}; + +class Cleanup:public CutsceneAction{ + public: + ActionType GetActionType() override{return ActionType::CLEANUP;} +}; + +class Object; + +class CreateObjects:public CutsceneAction{ + private: + std::vectorobjs; + public: + template + CreateObjects(std::initializer_list objs) { + for( auto elem : objs ) + { + this->objs.push_back(elem); + } + } + ActionType GetActionType() override{return ActionType::CREATE_OBJECTS;} + std::vector GetObjects(); + }; + +class PanCamera:public CutsceneAction{ + private: + vd2d targetPos; + PriorityDirection dir; + double cameraSpd; + public: + PanCamera(vd2d targetPos,PriorityDirection dir,double cameraSpd=CAMERA_MOVESPD) { + this->targetPos=targetPos; + this->dir=dir; + this->cameraSpd=cameraSpd; + } + ActionType GetActionType() override{return ActionType::PAN_CAMERA;} + vd2d GetCameraTargetPos() { + return targetPos; + } + PriorityDirection GetPriorityDirection() { + return dir; + } + double GetCameraSpeed() { + return cameraSpd; + } + }; + +/* +To use this class, specify multiple actions back-to-back, filling their appropriate arguments. + +In responsive events, poll what CurrentAction() is, and if it's suitable, then use LockAction() +to lock the event and perform whatever actions are required. When the cutscene action is complete, +you can advance the action using AdvanceAction(). +*/ +class Cutscene{ + private: + int actionMarker=0; + std::vector actions; + bool actionIsActive=false; + public: + template + Cutscene(std::initializer_list actions) { + AddAction(actions); + }; + template + void AddAction( std::initializer_list actions ) + { + for( auto elem : actions ) + { + this->actions.push_back(elem); + } + this->actions.push_back(new Cleanup()); + } + ActionType CurrentAction(){ + if (!actionIsActive&&actionMarkerGetActionType(); + } else { + return ActionType::NONE; + } + } + void LockAction() { + actionIsActive=true; + } + void AdvanceAction(){ + actionIsActive=false; + actionMarker++; + } + void ResetCutscene(){ + actionMarker=0; + actionIsActive=false; + } +}; \ No newline at end of file diff --git a/ideas b/ideas index cd16457..6cb705d 100644 --- a/ideas +++ b/ideas @@ -104,4 +104,14 @@ Battle Commands: Power Item Move Attack Defend Run -The Defend command will provide 80% damage reduction. \ No newline at end of file +The Defend command will provide 80% damage reduction. + + +======================== + +Cutscenes +Create and Move Objects +Pan the Camera +Fade the game In/Out +Start Dialog +Set Game Flags \ No newline at end of file diff --git a/main.cpp b/main.cpp index a9c1559..e09abb0 100644 --- a/main.cpp +++ b/main.cpp @@ -9,10 +9,10 @@ #include "states.h" #include "flags.h" #include +#include "cutscene.h" #define WIDTH 256 #define HEIGHT 224 -#define CAMERA_MOVESPD 5 #define TILEMAP_SIZE_X 512 #define TILEMAP_SIZE_Y 512 #define TILEMAP_EDITOR_DRAW_MULT 0.4375 @@ -78,6 +78,7 @@ class Object{ int disableFlag; int enableFlag; int objArrElement; //Which element in the object array this object is located in. For sorting purposes. + bool temp=false; //If set to true, it's marked for deletion after cutscene handling. //animationSpd is how long to wait before switching frames. Object(int id,std::string name,vd2d pos,Animation*spr,vd2d scale={1,1},Pixel color=WHITE,int animationSpd=1) { this->spr=spr; @@ -111,13 +112,13 @@ public: int MAP_HEIGHT=-1; Map*CURRENT_MAP; Map*MAP_ONETT; - vd2d cameraPos = {0,0}; int GAME_STATE = GameState::EDITOR; vi2d SELECTED_TILE={0,0}; vi2d HIGHLIGHTED_TILE={0,0}; int EDITING_LAYER=layer::DYNAMIC; int SELECTED_OBJ_ID = PLAYER; int OBJ_DISPLAY_OFFSET = 0; + vd2d cameraPos = {0,0}; bool GAME_FLAGS[128]={}; Object* PLAYER_OBJ; bool messageBoxVisible=false; @@ -130,6 +131,7 @@ public: int messageBoxFrameWaitTime=1; bool messageBoxLoad=false; //Set to true when ready to load a message in. std::map additionalChars; + Cutscene*TestCutscene; bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things. @@ -175,6 +177,13 @@ public: //OBJ_INFO["PLAYER"]=PLAYER_ANIMATION; LoadMap(MAP_ONETT); + TestCutscene=new Cutscene({ + (CutsceneAction*)new PanCamera({128,128},BOTH), + (CutsceneAction*)new PanCamera({128,128},BOTH), + (CutsceneAction*)new CreateObjects({ + new Object(PLAYER,"player",{64,64},ANIMATIONS["player.png"],{1,1},MAGENTA) + }),}); + /*DisplayMessageBox(R"(Hello World! This is a rather long message, but I hope it reaches you well in some form or capacity or another. Even though it @@ -567,8 +576,6 @@ goes on a very long time, I hope you can understand this is only for testing pur DrawStringPropDecal({6,6},messageBoxText); } SetDrawTarget(layer::INTERFACE); - DrawFancyStringDecal({8,8},L"Testing βtesting α\ntesting",RED); - DrawFancyStringDecal({36,64},L"TesΣting testing γ\ntestingΩ",RED,{2,2}); }; void DrawFancyStringDecal(const olc::vf2d& pos, const std::wstring& sText, const Pixel col = olc::WHITE, const olc::vf2d& scale = { 1.0f, 1.0f }) { @@ -1173,6 +1180,13 @@ goes on a very long time, I hope you can understand this is only for testing pur Draw({pos.x+size.x-1,pos.y},Pixel(77, 51, 125)); Draw({pos.x,pos.y+size.y-1},Pixel(77, 51, 125)); } + + void PlayCutscene(int scene) { + switch (scene) { + case cutscene::TEST_CUTSCENE:{ + }break; + } + } }; diff --git a/references.h b/references.h index eacb0bb..f751b66 100644 --- a/references.h +++ b/references.h @@ -152,4 +152,10 @@ enum Reference{ NPC17_8, NPC18_8, NPC19_8, -}; \ No newline at end of file +}; + +namespace cutscene{ + enum{ + TEST_CUTSCENE + }; +} \ No newline at end of file