|
|
|
@ -40,6 +40,7 @@ std::vector<Object*> OBJECTS; |
|
|
|
|
const vd2d NO_NEIGHBOR = {-999,-999}; |
|
|
|
|
SeasonI*GAME; |
|
|
|
|
|
|
|
|
|
//THIS VARIABLE SHOULD NOT BE UPDATED DIRECTLY! Use UpdateCamera(pos) to update the camera position!
|
|
|
|
|
vd2d cameraPos={0,0}; |
|
|
|
|
|
|
|
|
|
std::vector<Item*> PARTY_INVENTORY; |
|
|
|
@ -1389,7 +1390,7 @@ void SeasonI::updateGame(){ |
|
|
|
|
if (movementComponents.mag()>0) { |
|
|
|
|
movementComponents=movementComponents.norm(); |
|
|
|
|
PARTY_MEMBER_OBJ[0]->frameIndex+=frameCount%PARTY_MEMBER_OBJ[0]->animationSpd==0; |
|
|
|
|
if (PARTY_MEMBER_OBJ[0]->SmoothMove(movementComponents)) {` |
|
|
|
|
if (PARTY_MEMBER_OBJ[0]->SmoothMove(movementComponents)) { |
|
|
|
|
UpdatePlayerTrail(movementComponents,facingDir); |
|
|
|
|
for (int i=0;i<CURRENT_MAP->triggers.size();i++) { |
|
|
|
|
if (CURRENT_MAP->triggers[i]->IsInside(PARTY_MEMBER_OBJ[0]->GetPosWithOrigin())) { |
|
|
|
@ -4245,24 +4246,28 @@ void SeasonI::AdvanceMessageBox() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SeasonI::cameraUpdate() { |
|
|
|
|
vd2d adjustCamera=cameraPos; |
|
|
|
|
switch (GAME_STATE) { |
|
|
|
|
case GameState::EDITOR: |
|
|
|
|
case GameState::MAP_POSITION_SELECT:{ |
|
|
|
|
//CAMERA MOVEMENTS MUST BE LAST!!!
|
|
|
|
|
if (UpHeld()) { |
|
|
|
|
cameraPos.y-=CAMERA_MOVESPD; |
|
|
|
|
adjustCamera.y-=CAMERA_MOVESPD; |
|
|
|
|
} |
|
|
|
|
if (RightHeld()) { |
|
|
|
|
cameraPos.x+=CAMERA_MOVESPD; |
|
|
|
|
adjustCamera.x+=CAMERA_MOVESPD; |
|
|
|
|
} |
|
|
|
|
if (LeftHeld()) { |
|
|
|
|
cameraPos.x-=CAMERA_MOVESPD; |
|
|
|
|
adjustCamera.x-=CAMERA_MOVESPD; |
|
|
|
|
} |
|
|
|
|
if (DownHeld()) { |
|
|
|
|
cameraPos.y+=CAMERA_MOVESPD; |
|
|
|
|
adjustCamera.y+=CAMERA_MOVESPD; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
if (adjustCamera!=cameraPos) { |
|
|
|
|
UpdateCamera(adjustCamera); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SeasonI::StartEffect(Effect*eff) { |
|
|
|
@ -4608,9 +4613,26 @@ void SeasonI::DrawRollingCounter(const olc::vi2d &pos,int val,int*rollcounter,in |
|
|
|
|
DrawPartialDecal({(float)(pos.x+41),(float)(pos.y-1)},{7,9},SPRITES["rollingcounter.png"],{0,(float)(rollcounter[0]*13+rolloffset[0]+13)},{7,9},Pixel(255,255,255,boxAlpha)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SeasonI::UpdateCollisionGrid() { |
|
|
|
|
for (int x=-1;x<WIDTH/32+2;x++) { |
|
|
|
|
for (int y=-1;y<HEIGHT/32+2;y++) { |
|
|
|
|
int yTileOffset=cameraPos.y/32; |
|
|
|
|
int xTileOffset=cameraPos.x/32; |
|
|
|
|
char tiles=0; |
|
|
|
|
if (x+xTileOffset>=0&&x+xTileOffset<MAP_WIDTH&&y+yTileOffset>=0&&y+yTileOffset<MAP_HEIGHT) { |
|
|
|
|
if(MAP5[y+yTileOffset][x+xTileOffset]->tileX!=15||MAP5[y+yTileOffset][x+xTileOffset]->tileY!=15) { |
|
|
|
|
SetDrawTarget(layer::COLLISION); |
|
|
|
|
DrawPartialSprite({(int)(x*32-fmod(cameraPos.x,32)),(int)(y*32-fmod(cameraPos.y,32))},CURRENT_MAP->tileset->sprite,{(int)(MAP5[y+yTileOffset][x+xTileOffset]->tileX*32),(int)(MAP5[y+yTileOffset][x+xTileOffset]->tileY*32)},{32,32}); |
|
|
|
|
tiles|=1<<5; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SeasonI::DrawGameWorld() { |
|
|
|
|
for (int y=-1;y<HEIGHT/32+2;y++) { |
|
|
|
|
int yTileOffset = cameraPos.y/32; |
|
|
|
|
int yTileOffset=cameraPos.y/32; |
|
|
|
|
for (auto&obj:OBJECTS) { |
|
|
|
|
if (!obj->drawn&&(!obj->dead||EDITING_LAYER==layer::ENCOUNTER)&& |
|
|
|
|
(GetTileDegreeSafely(MAP2)==0&& |
|
|
|
@ -5002,18 +5024,21 @@ void SeasonI::DrawArrow() { |
|
|
|
|
|
|
|
|
|
bool SeasonI::MoveCameraTowardsPoint(vd2d targetPos,PriorityDirection dir,double spd,bool secondRun) { |
|
|
|
|
bool reachedPosition=true; |
|
|
|
|
vd2d newCameraPos=cameraPos; |
|
|
|
|
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; |
|
|
|
|
if (newCameraPos.x!=targetPos.x) { |
|
|
|
|
if (newCameraPos.x<targetPos.x) { |
|
|
|
|
newCameraPos.x+=spd; |
|
|
|
|
if (newCameraPos.x>targetPos.x) { |
|
|
|
|
newCameraPos.x=targetPos.x; |
|
|
|
|
} |
|
|
|
|
UpdateCamera(newCameraPos); |
|
|
|
|
} else { |
|
|
|
|
cameraPos.x-=spd; |
|
|
|
|
if (cameraPos.x<targetPos.x) { |
|
|
|
|
cameraPos.x=targetPos.x; |
|
|
|
|
newCameraPos.x-=spd; |
|
|
|
|
if (newCameraPos.x<targetPos.x) { |
|
|
|
|
newCameraPos.x=targetPos.x; |
|
|
|
|
} |
|
|
|
|
UpdateCamera(newCameraPos); |
|
|
|
|
} |
|
|
|
|
reachedPosition=false; |
|
|
|
|
} else |
|
|
|
@ -5022,17 +5047,19 @@ bool SeasonI::MoveCameraTowardsPoint(vd2d targetPos,PriorityDirection dir,double |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
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; |
|
|
|
|
if (newCameraPos.y!=targetPos.y) { |
|
|
|
|
if (newCameraPos.y<targetPos.y) { |
|
|
|
|
newCameraPos.y+=spd; |
|
|
|
|
if (newCameraPos.y>targetPos.y) { |
|
|
|
|
newCameraPos.y=targetPos.y; |
|
|
|
|
} |
|
|
|
|
UpdateCamera(newCameraPos); |
|
|
|
|
} else { |
|
|
|
|
cameraPos.y-=spd; |
|
|
|
|
if (cameraPos.y<targetPos.y) { |
|
|
|
|
cameraPos.y=targetPos.y; |
|
|
|
|
newCameraPos.y-=spd; |
|
|
|
|
if (newCameraPos.y<targetPos.y) { |
|
|
|
|
newCameraPos.y=targetPos.y; |
|
|
|
|
} |
|
|
|
|
UpdateCamera(newCameraPos); |
|
|
|
|
} |
|
|
|
|
reachedPosition=false; |
|
|
|
|
} else |
|
|
|
@ -5571,9 +5598,14 @@ void SeasonI::LoadGameSaveData(int saveSlot) { |
|
|
|
|
CHAPTER_NUMBER=ReadIntFromStream(file); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SeasonI::UpdateCamera(vd2d newpos) { |
|
|
|
|
cameraPos=newpos; |
|
|
|
|
UpdateCollisionGrid(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SeasonI::CenterCameraOnPlayer(){ |
|
|
|
|
const vi2d cameraOffset={WIDTH/2,HEIGHT/2}; |
|
|
|
|
cameraPos=PARTY_MEMBER_OBJ[0]->GetPos()+PARTY_MEMBER_OBJ[0]->originPoint/2-cameraOffset; |
|
|
|
|
UpdateCamera(PARTY_MEMBER_OBJ[0]->GetPos()+PARTY_MEMBER_OBJ[0]->originPoint/2-cameraOffset); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int SeasonI::GetPointQuadrantRelativeToLine(vi2d x1y1,vi2d x2y2,vi2d point){ |
|
|
|
|