Organize cutscenes and add map transition cutscene triggers

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 23f0a7b5d2
commit f1c347207a
  1. BIN
      C++ProjectTemplate
  2. 2
      SeasonI.h
  3. 3
      assets/maps/map0
  4. 2
      assets/maps/map0_5
  5. 3
      assets/maps/newmap
  6. 2
      assets/maps/newmap_5
  7. 35
      cutscene.h
  8. 53
      main.cpp
  9. 2
      trigger.cpp
  10. 17
      trigger.h

Binary file not shown.

@ -32,6 +32,7 @@ class SeasonI:public PixelGameEngine{
void SetupObjectInfo(); void SetupObjectInfo();
void SetupEncounters(); void SetupEncounters();
void SetupBattleProperties(); void SetupBattleProperties();
void SetupCutscenes();
void SetGameFlag(Flag flag,bool val); void SetGameFlag(Flag flag,bool val);
void LoadMap(Map*map); void LoadMap(Map*map);
void SaveMap(Map*map); void SaveMap(Map*map);
@ -125,6 +126,7 @@ class SeasonI:public PixelGameEngine{
bool Collision(vd2d pos); bool Collision(vd2d pos);
void DrawInventory(); void DrawInventory();
void ChoiceMade(int choice); void ChoiceMade(int choice);
void StartCutscene(Cutscene*cutscene);
}; };
extern SeasonI*GAME; extern SeasonI*GAME;
#endif #endif

@ -94,4 +94,5 @@ ENCOUNTER480.000000;160.000000;100;3
TRIGGER32;288;1;32;32 TRIGGER32;288;1;32;32
TRIGGER96;352;1;32;32 TRIGGER96;352;1;32;32
TRIGGER32;384;1;32;32 TRIGGER32;384;1;32;32
TRIGGER32;288;1;32;32 TRIGGER32;288;1;32;32
TRIGGER416;256;2;32;32

@ -7,7 +7,7 @@
??????????0717?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????????0717??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????93:3;3?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????93??;3??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????15?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????15??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????065656565616?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????????????????????065656565616??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????9256?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????????????????????9256??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

@ -68,4 +68,5 @@ TRIGGER64;352;1;32;32
TRIGGER96;352;1;32;32 TRIGGER96;352;1;32;32
TRIGGER96;384;1;32;32 TRIGGER96;384;1;32;32
TRIGGER64;384;1;32;32 TRIGGER64;384;1;32;32
TRIGGER32;384;1;32;32 TRIGGER32;384;1;32;32
TRIGGER416;256;3;32;32

@ -7,7 +7,7 @@
??????????0717?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????????0717??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????93:3;3?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????93??;3??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????15?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????15??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????065656565616?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????????????????????065656565616??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????9256?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????????????????????9256??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

@ -1,6 +1,7 @@
#ifndef CUTSCENE_H #ifndef CUTSCENE_H
#define CUTSCENE_H #define CUTSCENE_H
#include "pixelGameEngine.h" #include "pixelGameEngine.h"
#include "defines.h"
#include "flags.h" #include "flags.h"
#define CAMERA_MOVESPD 5 #define CAMERA_MOVESPD 5
@ -14,6 +15,14 @@ enum PriorityDirection{
BOTH BOTH
}; };
namespace CutsceneName{
enum Cutscene{
TEST_CUTSCENE,
TRANSFER_MAP_TWOSON_CUTSCENE,
TRANSFER_MAP_ONETT_CUTSCENE,
};
}
enum class ActionType{ enum class ActionType{
NONE, NONE,
PAN_CAMERA, PAN_CAMERA,
@ -28,6 +37,7 @@ enum class ActionType{
DIALOG_ASYNC, DIALOG_ASYNC,
MOVE_CUTSCENE_OBJ_ASYNC, MOVE_CUTSCENE_OBJ_ASYNC,
MODIFY_OBJECT, MODIFY_OBJECT,
LOAD_MAP,
}; };
class CutsceneAction{ class CutsceneAction{
@ -49,6 +59,7 @@ class Cleanup:public CutsceneAction{
class Object; class Object;
class Animation; class Animation;
class Map;
class CreateObjects:public CutsceneAction{ class CreateObjects:public CutsceneAction{
protected: protected:
@ -249,6 +260,18 @@ class ModifyObject:public CutsceneAction{
} }
}; };
class LoadMap:public CutsceneAction{
protected:
Map*map;
public:
LoadMap(Map*newMap)
:map(newMap) {}
ActionType GetActionType() override{return ActionType::LOAD_MAP;}
Map*GetTargetMap(){
return map;
}
};
/* /*
To use this class, specify multiple actions back-to-back, filling their appropriate arguments. To use this class, specify multiple actions back-to-back, filling their appropriate arguments.
@ -270,7 +293,7 @@ class Cutscene{
AddAction(actions); AddAction(actions);
}; };
template <class T> template <class T>
void AddAction( std::initializer_list<T> actions ) void AddAction(std::initializer_list<T> actions )
{ {
for( auto elem : actions ) for( auto elem : actions )
{ {
@ -327,4 +350,14 @@ class Cutscene{
return storedVal; return storedVal;
} }
}; };
class MapTransitionCutscene:public Cutscene{
public:
MapTransitionCutscene(Map*newmap)
:Cutscene({
Fade(),
LoadMap(newmap),
Fade(true),
}){}
};
#endif #endif

@ -75,7 +75,6 @@ int messageBoxStopMarker=0; //End of text display for current printout.
int messageBoxFrameWaitTime=1; int messageBoxFrameWaitTime=1;
bool messageBoxLoad=false; //Set to true when ready to load a message in. bool messageBoxLoad=false; //Set to true when ready to load a message in.
std::map<int,vi2d> additionalChars={}; std::map<int,vi2d> additionalChars={};
Cutscene*TestCutscene=nullptr;
Cutscene*CurrentCutscene=nullptr; Cutscene*CurrentCutscene=nullptr;
ActionType CurrentAction=ActionType::NONE; ActionType CurrentAction=ActionType::NONE;
double CUTSCENE_FADE_VALUE=0; double CUTSCENE_FADE_VALUE=0;
@ -203,6 +202,7 @@ std::vector<Particle*> PARTICLES={};
std::vector<DamageNumber*> DAMAGE_NUMBERS={}; std::vector<DamageNumber*> DAMAGE_NUMBERS={};
std::map<std::pair<int,int>,vd2d> MOVEMENT_GRID={}; std::map<std::pair<int,int>,vd2d> MOVEMENT_GRID={};
std::map<ItemName,Item*>ITEMLIST={}; std::map<ItemName,Item*>ITEMLIST={};
std::map<CutsceneName::Cutscene,Cutscene*> CUTSCENES={};
vi2d SELECTED_MOVE_SQUARE={}; vi2d SELECTED_MOVE_SQUARE={};
FountainEffect*FOUNTAIN_EFFECT=nullptr; FountainEffect*FOUNTAIN_EFFECT=nullptr;
@ -234,6 +234,7 @@ bool SeasonI::OnUserCreate(){
SetupObjectInfo(); SetupObjectInfo();
SetupEncounters(); SetupEncounters();
SetupBattleProperties(); SetupBattleProperties();
SetupCutscenes();
SetGameFlag(Flag::TEST_FLAG1,false); SetGameFlag(Flag::TEST_FLAG1,false);
SetGameFlag(Flag::TEST_FLAG2,false); SetGameFlag(Flag::TEST_FLAG2,false);
SetGameFlag(Flag::TEST_FLAG3,false); SetGameFlag(Flag::TEST_FLAG3,false);
@ -252,23 +253,6 @@ bool SeasonI::OnUserCreate(){
//OBJ_INFO["PLAYER"]=PLAYER_ANIMATION; //OBJ_INFO["PLAYER"]=PLAYER_ANIMATION;
LoadMap(CURRENT_MAP); LoadMap(CURRENT_MAP);
TestCutscene=new Cutscene({
Fade(),
CreateObjects({
new Standard_Obj(PLAYER,"player",{64,64},ANIMATIONS["player.png"],{1,1},MAGENTA),
new Standard_Obj(PLAYER,"player",{136,136},ANIMATIONS["player.png"],{1,1},RED),
new Standard_Obj(PLAYER,"player",{96,96},ANIMATIONS["player.png"],{1,1},DARK_GREEN),
}),
Fade(true),
SetFlagWhenCutsceneEnds(Flag::TEST_FLAG1),
PanCamera({128,128},BOTH,1),
MoveCutsceneObjectAsync(1,{80,64},5),
PanCamera({64,0},BOTH),
DialogBoxAsync(R"(Hello!
This is a test message that lets us trigger straight from a cutscene! Cool!)"),
ModifyObject(0,ANIMATIONS["player.png"],{5,5},MAGENTA),
MoveCutsceneObject(1,{320,64},1),});
AddItemToPlayerInventory(ItemName::LIGHT_JACKET); AddItemToPlayerInventory(ItemName::LIGHT_JACKET);
AddItemToPlayerInventory(ItemName::LIGHT_JACKET); AddItemToPlayerInventory(ItemName::LIGHT_JACKET);
AddItemToPlayerInventory(ItemName::HEAVY_JACKET); AddItemToPlayerInventory(ItemName::HEAVY_JACKET);
@ -3770,6 +3754,12 @@ void SeasonI::HandleCutscenes() {
obj->animationSpd=action->GetAnimationSpeed(); obj->animationSpd=action->GetAnimationSpeed();
CurrentCutscene->AdvanceAction(); CurrentCutscene->AdvanceAction();
}break; }break;
case ActionType::LOAD_MAP:{
class LoadMap*action=(class LoadMap*)CurrentCutscene->GetAction();
Map*map=action->GetTargetMap();
LoadMap(map);
CurrentCutscene->AdvanceAction();
}break;
} }
for (int i=0;i<CUTSCENE_QUEUE.size();i++) { for (int i=0;i<CUTSCENE_QUEUE.size();i++) {
@ -5052,6 +5042,33 @@ void SeasonI::ChoiceMade(int choice) {
} }
} }
void SeasonI::StartCutscene(Cutscene*cutscene) {
CurrentCutscene=cutscene;
}
void SeasonI::SetupCutscenes(){
CUTSCENES={
{CutsceneName::TEST_CUTSCENE,new Cutscene({
Fade(),
CreateObjects({
new Standard_Obj(PLAYER,"player",{64,64},ANIMATIONS["player.png"],{1,1},MAGENTA),
new Standard_Obj(PLAYER,"player",{136,136},ANIMATIONS["player.png"],{1,1},RED),
new Standard_Obj(PLAYER,"player",{96,96},ANIMATIONS["player.png"],{1,1},DARK_GREEN),
}),
Fade(true),
SetFlagWhenCutsceneEnds(Flag::TEST_FLAG1),
PanCamera({128,128},BOTH,1),
MoveCutsceneObjectAsync(1,{80,64},5),
PanCamera({64,0},BOTH),
DialogBoxAsync(R"(Hello!
This is a test message that lets us trigger straight from a cutscene! Cool!)"),
ModifyObject(0,ANIMATIONS["player.png"],{5,5},MAGENTA),
MoveCutsceneObject(1,{320,64},1),})},
{CutsceneName::TRANSFER_MAP_TWOSON_CUTSCENE,new MapTransitionCutscene(MAPS[MapName::TWOSON])},
{CutsceneName::TRANSFER_MAP_ONETT_CUTSCENE,new MapTransitionCutscene(MAPS[MapName::ONETT])},
};
}
#ifndef TEST_SUITE #ifndef TEST_SUITE
int main() int main()
{ {

@ -5,4 +5,6 @@ int TRIGGER_ENUM_COUNT=1;
std::map<TriggerName::Trigger,std::string> TRIGGERS={ std::map<TriggerName::Trigger,std::string> TRIGGERS={
{(TriggerName::Trigger)TRIGGER_ENUM_COUNT++,"START_CUTSCENE_1"}, {(TriggerName::Trigger)TRIGGER_ENUM_COUNT++,"START_CUTSCENE_1"},
{(TriggerName::Trigger)TRIGGER_ENUM_COUNT++,"Goto Twoson"},
{(TriggerName::Trigger)TRIGGER_ENUM_COUNT++,"Goto Onett"},
}; };

@ -1,5 +1,6 @@
#ifndef TRIGGER_H #ifndef TRIGGER_H
#define TRIGGER_H #define TRIGGER_H
#include "cutscene.h"
#include "pixelGameEngine.h" #include "pixelGameEngine.h"
#include "flags.h" #include "flags.h"
#include "SeasonI.h" #include "SeasonI.h"
@ -10,20 +11,24 @@ namespace TriggerName{
//When adding new triggers to the list, you will have to add a new line to trigger.cpp to get it to appear in the editor. //When adding new triggers to the list, you will have to add a new line to trigger.cpp to get it to appear in the editor.
enum Trigger{ enum Trigger{
NONE, NONE,
START_CUTSCENE_1 START_CUTSCENE_1,
GOTO_TWOSON_MAP,
GOTO_ONETT_MAP
}; };
} }
extern void DisplayMessageBox(std::string targetT); extern void DisplayMessageBox(std::string targetT);
extern SeasonI*GAME; extern SeasonI*GAME;
extern std::map<CutsceneName::Cutscene,Cutscene*> CUTSCENES;
class Trigger{ class Trigger{
vi2d pos; vi2d pos;
vi2d size; vi2d size;
TriggerName::Trigger id; TriggerName::Trigger id;
vi2d extraCoords;
public: public:
Trigger(vi2d pos,vi2d size,TriggerName::Trigger id) Trigger(vi2d pos,vi2d size,TriggerName::Trigger id,vi2d extraCoords={0,0})
:pos(pos),size(size),id(id){} :pos(pos),size(size),id(id),extraCoords(extraCoords){}
bool IsInside(vd2d point) { bool IsInside(vd2d point) {
return point.x>pos.x&&point.x<pos.x+size.x&&point.y>pos.y&&point.y<pos.y+size.y; return point.x>pos.x&&point.x<pos.x+size.x&&point.y>pos.y&&point.y<pos.y+size.y;
} }
@ -35,6 +40,12 @@ class Trigger{
GAME->SetGameFlag(Flag::TEST_FLAG1,true); GAME->SetGameFlag(Flag::TEST_FLAG1,true);
} }
}break; }break;
case TriggerName::GOTO_TWOSON_MAP:{
GAME->StartCutscene(CUTSCENES[CutsceneName::TRANSFER_MAP_TWOSON_CUTSCENE]);
}break;
case TriggerName::GOTO_ONETT_MAP:{
GAME->StartCutscene(CUTSCENES[CutsceneName::TRANSFER_MAP_ONETT_CUTSCENE]);
}break;
} }
} }
vi2d GetPos() { vi2d GetPos() {

Loading…
Cancel
Save