diff --git a/C++ProjectTemplate b/C++ProjectTemplate index a8ef353..a429506 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/cutscene.h b/cutscene.h index cc3a244..fbdcb7d 100644 --- a/cutscene.h +++ b/cutscene.h @@ -1,6 +1,7 @@ #include "pixelGameEngine.h" #define CAMERA_MOVESPD 5 +#define BATTLE_CAMERA_MOVESPD 2.5 using namespace olc; diff --git a/main.cpp b/main.cpp index 22add82..3867ec7 100644 --- a/main.cpp +++ b/main.cpp @@ -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;iplayerPos[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;iGetActionType()) { 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.xGetCameraTargetPos().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.xtargetPos.x) { + cameraPos.x=targetPos.x; } } else { - cameraPos.x-=pan->GetCameraSpeed(); - if (cameraPos.xGetCameraTargetPos().x) { - cameraPos.x=pan->GetCameraTargetPos().x; + cameraPos.x-=spd; + if (cameraPos.xGetPriorityDirection()!=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.yGetCameraTargetPos().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.ytargetPos.y) { + cameraPos.y=targetPos.y; } } else { - cameraPos.y-=pan->GetCameraSpeed(); - if (cameraPos.yGetCameraTargetPos().y) { - cameraPos.y=pan->GetCameraTargetPos().y; + cameraPos.y-=spd; + if (cameraPos.yGetPriorityDirection()!=BOTH) { - MoveCameraTowardsPoint(pan,true); + if (!secondRun&&dir!=BOTH) { + MoveCameraTowardsPoint(targetPos,dir,spd,true); } } return reachedPosition;