cutscene manager first pieces implementation

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 768b010016
commit 74e328c8f0
  1. BIN
      C++ProjectTemplate
  2. 20
      assets/maps/map0
  3. 115
      cutscene.h
  4. 10
      ideas
  5. 22
      main.cpp
  6. 6
      references.h

Binary file not shown.

@ -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

@ -0,0 +1,115 @@
#include "pixelGameEngine.h"
#include <cstdarg>
#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::vector<Object*>objs;
public:
template <class T>
CreateObjects(std::initializer_list<T> objs) {
for( auto elem : objs )
{
this->objs.push_back(elem);
}
}
ActionType GetActionType() override{return ActionType::CREATE_OBJECTS;}
std::vector<Object*> 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<CutsceneAction*> actions;
bool actionIsActive=false;
public:
template <class T>
Cutscene(std::initializer_list<T> actions) {
AddAction(actions);
};
template <class T>
void AddAction( std::initializer_list<T> actions )
{
for( auto elem : actions )
{
this->actions.push_back(elem);
}
this->actions.push_back(new Cleanup());
}
ActionType CurrentAction(){
if (!actionIsActive&&actionMarker<actions.size()) {
return actions[actionMarker]->GetActionType();
} else {
return ActionType::NONE;
}
}
void LockAction() {
actionIsActive=true;
}
void AdvanceAction(){
actionIsActive=false;
actionMarker++;
}
void ResetCutscene(){
actionMarker=0;
actionIsActive=false;
}
};

10
ideas

@ -105,3 +105,13 @@ Power Item Move
Attack Defend Run
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

@ -9,10 +9,10 @@
#include "states.h"
#include "flags.h"
#include <assert.h>
#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<int,vi2d> 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;
}
}
};

@ -153,3 +153,9 @@ enum Reference{
NPC18_8,
NPC19_8,
};
namespace cutscene{
enum{
TEST_CUTSCENE
};
}
Loading…
Cancel
Save