Battle camera move mode setup

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent a5a857638c
commit b80eb56837
  1. BIN
      C++ProjectTemplate
  2. 1
      cutscene.h
  3. 64
      main.cpp

Binary file not shown.

@ -1,6 +1,7 @@
#include "pixelGameEngine.h"
#define CAMERA_MOVESPD 5
#define BATTLE_CAMERA_MOVESPD 2.5
using namespace olc;

@ -520,13 +520,25 @@ goes on a very long time, I hope you can understand this is only for testing pur
CurrentCutscene->LockAction();
}
if (BATTLE_ENCOUNTER!=nullptr) {
switch (BATTLE_STATE) {
case BattleState::MOVE_CAMERA:{
MoveCameraTowardsPoint(BATTLE_ENCOUNTER->pos,PriorityDirection::BOTH,BATTLE_CAMERA_MOVESPD);
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
MoveObjectTowardsPoint(PARTY_MEMBER_OBJ[i],BATTLE_ENCOUNTER->playerPos[i]+BATTLE_ENCOUNTER->pos,PriorityDirection::BOTH,BATTLE_CAMERA_MOVESPD);
}
}break;
}
}
switch (CurrentAction) {
case ActionType::SET_FLAG_WHEN_CUTSCENE_ENDS:{
CurrentCutscene->SetupEndingCutsceneFlag(((SetFlagWhenCutsceneEnds*)CurrentCutscene->GetAction())->GetCutsceneEndingFlag(),((SetFlagWhenCutsceneEnds*)CurrentCutscene->GetAction())->GetCutsceneEndingVal());
CurrentCutscene->AdvanceAction();
}break;
case ActionType::PAN_CAMERA:{
if (MoveCameraTowardsPoint((PanCamera*)CurrentCutscene->GetAction())) {
PanCamera*cam=(PanCamera*)CurrentCutscene->GetAction();
if (MoveCameraTowardsPoint(cam->GetCameraTargetPos(),cam->GetPriorityDirection(),cam->GetCameraSpeed())) {
CurrentCutscene->AdvanceAction();
}
}break;
@ -612,7 +624,8 @@ goes on a very long time, I hope you can understand this is only for testing pur
for (int i=0;i<CUTSCENE_QUEUE.size();i++) {
switch (CUTSCENE_QUEUE[i]->GetActionType()) {
case ActionType::PAN_CAMERA_ASYNC:{
if (MoveCameraTowardsPoint((PanCameraAsync*)CUTSCENE_QUEUE[i])) {
PanCameraAsync*cam=(PanCameraAsync*)CUTSCENE_QUEUE[i];
if (MoveCameraTowardsPoint(cam->GetCameraTargetPos(),cam->GetPriorityDirection(),cam->GetCameraSpeed())) {
CUTSCENE_QUEUE.erase(CUTSCENE_QUEUE.begin()+i--);
}
}break;
@ -905,6 +918,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
}
if (GetKey(F5).bPressed) {
GAME_STATE=GameState::GAME_WORLD;
EDITING_LAYER=layer::DYNAMIC;
}
if (GetKey(K1).bPressed) {
EDITING_LAYER=layer::COLLISION;
@ -1781,44 +1795,44 @@ goes on a very long time, I hope you can understand this is only for testing pur
return (CurrentCutscene==nullptr)?ActionType::NONE:CurrentCutscene->CurrentAction();
}
bool MoveCameraTowardsPoint(PanCamera*pan,bool secondRun=false) {
bool MoveCameraTowardsPoint(vd2d targetPos,PriorityDirection dir,double spd,bool secondRun=false) {
bool reachedPosition=true;
if (pan->GetPriorityDirection()==HORZ_FIRST||pan->GetPriorityDirection()==BOTH) {
if (cameraPos.x!=pan->GetCameraTargetPos().x) {
if (cameraPos.x<pan->GetCameraTargetPos().x) {
cameraPos.x+=pan->GetCameraSpeed();
if (cameraPos.x>pan->GetCameraTargetPos().x) {
cameraPos.x=pan->GetCameraTargetPos().x;
if (dir==HORZ_FIRST||dir==BOTH) {
if (cameraPos.x!=targetPos.x) {
if (cameraPos.x<targetPos.x) {
cameraPos.x+=spd;
if (cameraPos.x>targetPos.x) {
cameraPos.x=targetPos.x;
}
} else {
cameraPos.x-=pan->GetCameraSpeed();
if (cameraPos.x<pan->GetCameraTargetPos().x) {
cameraPos.x=pan->GetCameraTargetPos().x;
cameraPos.x-=spd;
if (cameraPos.x<targetPos.x) {
cameraPos.x=targetPos.x;
}
}
reachedPosition=false;
} else
if (!secondRun&&pan->GetPriorityDirection()!=BOTH) {
MoveCameraTowardsPoint(pan,true);
if (!secondRun&&dir!=BOTH) {
MoveCameraTowardsPoint(targetPos,dir,spd,true);
}
}
if (pan->GetPriorityDirection()==VERT_FIRST||pan->GetPriorityDirection()==BOTH) {
if (cameraPos.y!=pan->GetCameraTargetPos().y) {
if (cameraPos.y<pan->GetCameraTargetPos().y) {
cameraPos.y+=pan->GetCameraSpeed();
if (cameraPos.y>pan->GetCameraTargetPos().y) {
cameraPos.y=pan->GetCameraTargetPos().y;
if (dir==VERT_FIRST||dir==BOTH) {
if (cameraPos.y!=targetPos.y) {
if (cameraPos.y<targetPos.y) {
cameraPos.y+=spd;
if (cameraPos.y>targetPos.y) {
cameraPos.y=targetPos.y;
}
} else {
cameraPos.y-=pan->GetCameraSpeed();
if (cameraPos.y<pan->GetCameraTargetPos().y) {
cameraPos.y=pan->GetCameraTargetPos().y;
cameraPos.y-=spd;
if (cameraPos.y<targetPos.y) {
cameraPos.y=targetPos.y;
}
}
reachedPosition=false;
} else
if (!secondRun&&pan->GetPriorityDirection()!=BOTH) {
MoveCameraTowardsPoint(pan,true);
if (!secondRun&&dir!=BOTH) {
MoveCameraTowardsPoint(targetPos,dir,spd,true);
}
}
return reachedPosition;

Loading…
Cancel
Save