generated from sigonasr2/CPlusPlusProjectTemplate
Battle camera move mode setup
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
a5a857638c
commit
b80eb56837
Binary file not shown.
@ -1,6 +1,7 @@
|
|||||||
#include "pixelGameEngine.h"
|
#include "pixelGameEngine.h"
|
||||||
|
|
||||||
#define CAMERA_MOVESPD 5
|
#define CAMERA_MOVESPD 5
|
||||||
|
#define BATTLE_CAMERA_MOVESPD 2.5
|
||||||
|
|
||||||
using namespace olc;
|
using namespace olc;
|
||||||
|
|
||||||
|
64
main.cpp
64
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();
|
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) {
|
switch (CurrentAction) {
|
||||||
case ActionType::SET_FLAG_WHEN_CUTSCENE_ENDS:{
|
case ActionType::SET_FLAG_WHEN_CUTSCENE_ENDS:{
|
||||||
CurrentCutscene->SetupEndingCutsceneFlag(((SetFlagWhenCutsceneEnds*)CurrentCutscene->GetAction())->GetCutsceneEndingFlag(),((SetFlagWhenCutsceneEnds*)CurrentCutscene->GetAction())->GetCutsceneEndingVal());
|
CurrentCutscene->SetupEndingCutsceneFlag(((SetFlagWhenCutsceneEnds*)CurrentCutscene->GetAction())->GetCutsceneEndingFlag(),((SetFlagWhenCutsceneEnds*)CurrentCutscene->GetAction())->GetCutsceneEndingVal());
|
||||||
CurrentCutscene->AdvanceAction();
|
CurrentCutscene->AdvanceAction();
|
||||||
}break;
|
}break;
|
||||||
case ActionType::PAN_CAMERA:{
|
case ActionType::PAN_CAMERA:{
|
||||||
if (MoveCameraTowardsPoint((PanCamera*)CurrentCutscene->GetAction())) {
|
PanCamera*cam=(PanCamera*)CurrentCutscene->GetAction();
|
||||||
|
if (MoveCameraTowardsPoint(cam->GetCameraTargetPos(),cam->GetPriorityDirection(),cam->GetCameraSpeed())) {
|
||||||
CurrentCutscene->AdvanceAction();
|
CurrentCutscene->AdvanceAction();
|
||||||
}
|
}
|
||||||
}break;
|
}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++) {
|
for (int i=0;i<CUTSCENE_QUEUE.size();i++) {
|
||||||
switch (CUTSCENE_QUEUE[i]->GetActionType()) {
|
switch (CUTSCENE_QUEUE[i]->GetActionType()) {
|
||||||
case ActionType::PAN_CAMERA_ASYNC:{
|
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--);
|
CUTSCENE_QUEUE.erase(CUTSCENE_QUEUE.begin()+i--);
|
||||||
}
|
}
|
||||||
}break;
|
}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) {
|
if (GetKey(F5).bPressed) {
|
||||||
GAME_STATE=GameState::GAME_WORLD;
|
GAME_STATE=GameState::GAME_WORLD;
|
||||||
|
EDITING_LAYER=layer::DYNAMIC;
|
||||||
}
|
}
|
||||||
if (GetKey(K1).bPressed) {
|
if (GetKey(K1).bPressed) {
|
||||||
EDITING_LAYER=layer::COLLISION;
|
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();
|
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;
|
bool reachedPosition=true;
|
||||||
if (pan->GetPriorityDirection()==HORZ_FIRST||pan->GetPriorityDirection()==BOTH) {
|
if (dir==HORZ_FIRST||dir==BOTH) {
|
||||||
if (cameraPos.x!=pan->GetCameraTargetPos().x) {
|
if (cameraPos.x!=targetPos.x) {
|
||||||
if (cameraPos.x<pan->GetCameraTargetPos().x) {
|
if (cameraPos.x<targetPos.x) {
|
||||||
cameraPos.x+=pan->GetCameraSpeed();
|
cameraPos.x+=spd;
|
||||||
if (cameraPos.x>pan->GetCameraTargetPos().x) {
|
if (cameraPos.x>targetPos.x) {
|
||||||
cameraPos.x=pan->GetCameraTargetPos().x;
|
cameraPos.x=targetPos.x;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cameraPos.x-=pan->GetCameraSpeed();
|
cameraPos.x-=spd;
|
||||||
if (cameraPos.x<pan->GetCameraTargetPos().x) {
|
if (cameraPos.x<targetPos.x) {
|
||||||
cameraPos.x=pan->GetCameraTargetPos().x;
|
cameraPos.x=targetPos.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reachedPosition=false;
|
reachedPosition=false;
|
||||||
} else
|
} else
|
||||||
if (!secondRun&&pan->GetPriorityDirection()!=BOTH) {
|
if (!secondRun&&dir!=BOTH) {
|
||||||
MoveCameraTowardsPoint(pan,true);
|
MoveCameraTowardsPoint(targetPos,dir,spd,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pan->GetPriorityDirection()==VERT_FIRST||pan->GetPriorityDirection()==BOTH) {
|
if (dir==VERT_FIRST||dir==BOTH) {
|
||||||
if (cameraPos.y!=pan->GetCameraTargetPos().y) {
|
if (cameraPos.y!=targetPos.y) {
|
||||||
if (cameraPos.y<pan->GetCameraTargetPos().y) {
|
if (cameraPos.y<targetPos.y) {
|
||||||
cameraPos.y+=pan->GetCameraSpeed();
|
cameraPos.y+=spd;
|
||||||
if (cameraPos.y>pan->GetCameraTargetPos().y) {
|
if (cameraPos.y>targetPos.y) {
|
||||||
cameraPos.y=pan->GetCameraTargetPos().y;
|
cameraPos.y=targetPos.y;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cameraPos.y-=pan->GetCameraSpeed();
|
cameraPos.y-=spd;
|
||||||
if (cameraPos.y<pan->GetCameraTargetPos().y) {
|
if (cameraPos.y<targetPos.y) {
|
||||||
cameraPos.y=pan->GetCameraTargetPos().y;
|
cameraPos.y=targetPos.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reachedPosition=false;
|
reachedPosition=false;
|
||||||
} else
|
} else
|
||||||
if (!secondRun&&pan->GetPriorityDirection()!=BOTH) {
|
if (!secondRun&&dir!=BOTH) {
|
||||||
MoveCameraTowardsPoint(pan,true);
|
MoveCameraTowardsPoint(targetPos,dir,spd,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return reachedPosition;
|
return reachedPosition;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user