generated from sigonasr2/CPlusPlusProjectTemplate
Organize cutscenes and add map transition cutscene triggers
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
23f0a7b5d2
commit
f1c347207a
Binary file not shown.
@ -32,6 +32,7 @@ class SeasonI:public PixelGameEngine{
|
||||
void SetupObjectInfo(); 됐어
|
||||
void SetupEncounters(); 됐어
|
||||
void SetupBattleProperties(); 됐어
|
||||
void SetupCutscenes();
|
||||
void SetGameFlag(Flag flag,bool val);
|
||||
void LoadMap(Map*map);
|
||||
void SaveMap(Map*map);
|
||||
@ -125,6 +126,7 @@ class SeasonI:public PixelGameEngine{
|
||||
bool Collision(vd2d pos);
|
||||
void DrawInventory();
|
||||
void ChoiceMade(int choice);
|
||||
void StartCutscene(Cutscene*cutscene);
|
||||
};
|
||||
extern SeasonI*GAME;
|
||||
#endif
|
@ -95,3 +95,4 @@ TRIGGER32;288;1;32;32
|
||||
TRIGGER96;352;1;32;32
|
||||
TRIGGER32;384;1;32;32
|
||||
TRIGGER32;288;1;32;32
|
||||
TRIGGER416;256;2;32;32
|
@ -7,7 +7,7 @@
|
||||
??????????0717??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
????????????????????????93:3;3??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
????????????????????????93??;3??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
????????????????????????????????15??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
??????????????????????065656565616??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
??????????????????????9256??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
|
@ -69,3 +69,4 @@ TRIGGER96;352;1;32;32
|
||||
TRIGGER96;384;1;32;32
|
||||
TRIGGER64;384;1;32;32
|
||||
TRIGGER32;384;1;32;32
|
||||
TRIGGER416;256;3;32;32
|
@ -7,7 +7,7 @@
|
||||
??????????0717??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
????????????????????????93:3;3??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
????????????????????????93??;3??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
????????????????????????????????15??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
??????????????????????065656565616??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
??????????????????????9256??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||
|
33
cutscene.h
33
cutscene.h
@ -1,6 +1,7 @@
|
||||
#ifndef CUTSCENE_H
|
||||
#define CUTSCENE_H
|
||||
#include "pixelGameEngine.h"
|
||||
#include "defines.h"
|
||||
#include "flags.h"
|
||||
|
||||
#define CAMERA_MOVESPD 5
|
||||
@ -14,6 +15,14 @@ enum PriorityDirection{
|
||||
BOTH
|
||||
};
|
||||
|
||||
namespace CutsceneName{
|
||||
enum Cutscene{
|
||||
TEST_CUTSCENE,
|
||||
TRANSFER_MAP_TWOSON_CUTSCENE,
|
||||
TRANSFER_MAP_ONETT_CUTSCENE,
|
||||
};
|
||||
}
|
||||
|
||||
enum class ActionType{
|
||||
NONE,
|
||||
PAN_CAMERA,
|
||||
@ -28,6 +37,7 @@ enum class ActionType{
|
||||
DIALOG_ASYNC,
|
||||
MOVE_CUTSCENE_OBJ_ASYNC,
|
||||
MODIFY_OBJECT,
|
||||
LOAD_MAP,
|
||||
};
|
||||
|
||||
class CutsceneAction{
|
||||
@ -49,6 +59,7 @@ class Cleanup:public CutsceneAction{
|
||||
|
||||
class Object;
|
||||
class Animation;
|
||||
class Map;
|
||||
|
||||
class CreateObjects:public CutsceneAction{
|
||||
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.
|
||||
|
||||
@ -327,4 +350,14 @@ class Cutscene{
|
||||
return storedVal;
|
||||
}
|
||||
};
|
||||
|
||||
class MapTransitionCutscene:public Cutscene{
|
||||
public:
|
||||
MapTransitionCutscene(Map*newmap)
|
||||
:Cutscene({
|
||||
액션 Fade(),
|
||||
액션 LoadMap(newmap),
|
||||
액션 Fade(true),
|
||||
}){}
|
||||
};
|
||||
#endif
|
53
main.cpp
53
main.cpp
@ -75,7 +75,6 @@ int messageBoxStopMarker=0; //End of text display for current printout.
|
||||
int messageBoxFrameWaitTime=1;
|
||||
bool messageBoxLoad=false; //Set to true when ready to load a message in.
|
||||
std::map<int,vi2d> additionalChars={};
|
||||
Cutscene*TestCutscene=nullptr;
|
||||
Cutscene*CurrentCutscene=nullptr;
|
||||
ActionType CurrentAction=ActionType::NONE;
|
||||
double CUTSCENE_FADE_VALUE=0;
|
||||
@ -203,6 +202,7 @@ std::vector<Particle*> PARTICLES={};
|
||||
std::vector<DamageNumber*> DAMAGE_NUMBERS={};
|
||||
std::map<std::pair<int,int>,vd2d> MOVEMENT_GRID={};
|
||||
std::map<ItemName,Item*>ITEMLIST={};
|
||||
std::map<CutsceneName::Cutscene,Cutscene*> CUTSCENES={};
|
||||
vi2d SELECTED_MOVE_SQUARE={};
|
||||
|
||||
FountainEffect*FOUNTAIN_EFFECT=nullptr;
|
||||
@ -234,6 +234,7 @@ bool SeasonI::OnUserCreate(){
|
||||
SetupObjectInfo();
|
||||
SetupEncounters();
|
||||
SetupBattleProperties();
|
||||
SetupCutscenes();
|
||||
SetGameFlag(Flag::TEST_FLAG1,false);
|
||||
SetGameFlag(Flag::TEST_FLAG2,false);
|
||||
SetGameFlag(Flag::TEST_FLAG3,false);
|
||||
@ -252,23 +253,6 @@ bool SeasonI::OnUserCreate(){
|
||||
//OBJ_INFO["PLAYER"]=PLAYER_ANIMATION;
|
||||
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::HEAVY_JACKET);
|
||||
@ -3770,6 +3754,12 @@ void SeasonI::HandleCutscenes() {
|
||||
obj->animationSpd=action->GetAnimationSpeed();
|
||||
CurrentCutscene->AdvanceAction();
|
||||
}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++) {
|
||||
@ -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
|
||||
int main()
|
||||
{
|
||||
|
@ -5,4 +5,6 @@ int TRIGGER_ENUM_COUNT=1;
|
||||
|
||||
std::map<TriggerName::Trigger,std::string> TRIGGERS={
|
||||
{(TriggerName::Trigger)TRIGGER_ENUM_COUNT++,"START_CUTSCENE_1"},
|
||||
{(TriggerName::Trigger)TRIGGER_ENUM_COUNT++,"Goto Twoson"},
|
||||
{(TriggerName::Trigger)TRIGGER_ENUM_COUNT++,"Goto Onett"},
|
||||
};
|
17
trigger.h
17
trigger.h
@ -1,5 +1,6 @@
|
||||
#ifndef TRIGGER_H
|
||||
#define TRIGGER_H
|
||||
#include "cutscene.h"
|
||||
#include "pixelGameEngine.h"
|
||||
#include "flags.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.
|
||||
enum Trigger{
|
||||
NONE,
|
||||
START_CUTSCENE_1
|
||||
START_CUTSCENE_1,
|
||||
GOTO_TWOSON_MAP,
|
||||
GOTO_ONETT_MAP
|
||||
};
|
||||
}
|
||||
|
||||
extern void DisplayMessageBox(std::string targetT);
|
||||
extern SeasonI*GAME;
|
||||
extern std::map<CutsceneName::Cutscene,Cutscene*> CUTSCENES;
|
||||
|
||||
class Trigger{
|
||||
vi2d pos;
|
||||
vi2d size;
|
||||
TriggerName::Trigger id;
|
||||
vi2d extraCoords;
|
||||
public:
|
||||
Trigger(vi2d pos,vi2d size,TriggerName::Trigger id)
|
||||
:pos(pos),size(size),id(id){}
|
||||
Trigger(vi2d pos,vi2d size,TriggerName::Trigger id,vi2d extraCoords={0,0})
|
||||
:pos(pos),size(size),id(id),extraCoords(extraCoords){}
|
||||
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;
|
||||
}
|
||||
@ -35,6 +40,12 @@ class Trigger{
|
||||
GAME->SetGameFlag(Flag::TEST_FLAG1,true);
|
||||
}
|
||||
}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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user