diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 4d9cf31..38d0972 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/cutscene.h b/cutscene.h index ddf8462..ebd18b5 100644 --- a/cutscene.h +++ b/cutscene.h @@ -16,7 +16,8 @@ enum class ActionType{ PAN_CAMERA, CREATE_OBJECTS, CLEANUP, - SET_FLAG_WHEN_CUTSCENE_ENDS + SET_FLAG_WHEN_CUTSCENE_ENDS, + FADE, }; class CutsceneAction{ @@ -89,6 +90,26 @@ class SetFlagWhenCutsceneEnds:public CutsceneAction{ } }; +class Fade:public CutsceneAction{ + private: + bool fadeIn=true; //If false, it fades out instead. + double fadeSpd=0; + public: + //If false, it fades out instead. + Fade(bool fadeIn=false,double fadeSpd=1) { + this->fadeIn=fadeIn; + this->fadeSpd=fadeSpd; + } + ActionType GetActionType() override{return ActionType::FADE;} + //If false, then it means we need to fade out instead. + bool FadeIn() { + return fadeIn; + } + double GetFadeSpd() { + return fadeSpd; + } + }; + /* To use this class, specify multiple actions back-to-back, filling their appropriate arguments. diff --git a/flags.h b/flags.h index 529b9f8..f51b6a4 100644 --- a/flags.h +++ b/flags.h @@ -8,8 +8,7 @@ enum class Flag:int{ template -auto flagint(Enumeration const value) - -> typename std::underlying_type::type +auto flagint(Enumeration const value) -> typename std::underlying_type::type { return static_cast::type>(value); } \ No newline at end of file diff --git a/main.cpp b/main.cpp index e3ed016..ee5f82c 100644 --- a/main.cpp +++ b/main.cpp @@ -182,6 +182,8 @@ public: LoadMap(MAP_ONETT); TestCutscene=new Cutscene({ + (CutsceneAction*)new Fade(), + (CutsceneAction*)new Fade(true), (CutsceneAction*)new SetFlagWhenCutsceneEnds(Flag::TEST_FLAG1), (CutsceneAction*)new PanCamera({128,128},BOTH), (CutsceneAction*)new PanCamera({128,0},BOTH), @@ -291,6 +293,20 @@ goes on a very long time, I hope you can understand this is only for testing pur CurrentCutscene=nullptr; CurrentAction=ActionType::NONE; }break; + case ActionType::FADE:{ + if (((Fade*)CurrentCutscene->GetAction())->FadeIn()&&CUTSCENE_FADE_VALUE>0) { + CUTSCENE_FADE_VALUE=std::clamp(CUTSCENE_FADE_VALUE-((Fade*)CurrentCutscene->GetAction())->GetFadeSpd(),0.0,255.0); + if (CUTSCENE_FADE_VALUE==0) { + CurrentCutscene->AdvanceAction(); + } + } else + if (!((Fade*)CurrentCutscene->GetAction())->FadeIn()&&CUTSCENE_FADE_VALUE<255) { + CUTSCENE_FADE_VALUE=std::clamp(CUTSCENE_FADE_VALUE+((Fade*)CurrentCutscene->GetAction())->GetFadeSpd(),0.0,255.0); + if (CUTSCENE_FADE_VALUE==255) { + CurrentCutscene->AdvanceAction(); + } + } + }break; }