|
|
|
@ -120,6 +120,7 @@ public: |
|
|
|
|
int OBJ_DISPLAY_OFFSET = 0; |
|
|
|
|
bool GAME_FLAGS[128]={}; |
|
|
|
|
Object* PLAYER_OBJ; |
|
|
|
|
bool messageBoxVisible=false; |
|
|
|
|
|
|
|
|
|
bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things.
|
|
|
|
|
|
|
|
|
@ -198,8 +199,6 @@ public: |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::cout << Collision(GetMousePos()); |
|
|
|
|
|
|
|
|
|
switch (GAME_STATE) { |
|
|
|
|
case GameState::TILE_SELECT:{ |
|
|
|
|
if (!TabHeld()) { |
|
|
|
@ -217,26 +216,18 @@ public: |
|
|
|
|
if (TabHeld()) { |
|
|
|
|
GAME_STATE=GameState::TILE_SELECT; |
|
|
|
|
} |
|
|
|
|
if (OBJECTS.size()>0) { |
|
|
|
|
if (PlayerCanMove()) { |
|
|
|
|
if (GetKey(I).bHeld) { |
|
|
|
|
if (!Collision({PLAYER_OBJ->pos.x+PLAYER_OBJ->originPoint.x,PLAYER_OBJ->pos.y-1+PLAYER_OBJ->originPoint.y})) { |
|
|
|
|
Move(PLAYER_OBJ,{0,-1}); |
|
|
|
|
} |
|
|
|
|
SmoothMove(PLAYER_OBJ,{0,-1}); |
|
|
|
|
} |
|
|
|
|
if (GetKey(K).bHeld) { |
|
|
|
|
if (!Collision({PLAYER_OBJ->pos.x+PLAYER_OBJ->originPoint.x,PLAYER_OBJ->pos.y+1+PLAYER_OBJ->originPoint.y})) { |
|
|
|
|
Move(PLAYER_OBJ,{0,1}); |
|
|
|
|
} |
|
|
|
|
SmoothMove(PLAYER_OBJ,{0,1}); |
|
|
|
|
} |
|
|
|
|
if (GetKey(J).bHeld) { |
|
|
|
|
if (!Collision({PLAYER_OBJ->pos.x-1+PLAYER_OBJ->originPoint.x,PLAYER_OBJ->pos.y+PLAYER_OBJ->originPoint.y})) { |
|
|
|
|
Move(PLAYER_OBJ,{-1,0}); |
|
|
|
|
} |
|
|
|
|
SmoothMove(PLAYER_OBJ,{-1,0}); |
|
|
|
|
} |
|
|
|
|
if (GetKey(L).bHeld) { |
|
|
|
|
if (!Collision({PLAYER_OBJ->pos.x+1+PLAYER_OBJ->originPoint.x,PLAYER_OBJ->pos.y+PLAYER_OBJ->originPoint.y})) { |
|
|
|
|
Move(PLAYER_OBJ,{1,0}); |
|
|
|
|
} |
|
|
|
|
SmoothMove(PLAYER_OBJ,{1,0}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
int selectedTileX=(GetMouseX()+cameraPos.x)/32; |
|
|
|
@ -909,6 +900,79 @@ public: |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SmoothMove(Object*obj,vd2d move) { |
|
|
|
|
const int wiggleRoom=3; |
|
|
|
|
vd2d originPos = {obj->pos.x+obj->originPoint.x,obj->pos.y-1+obj->originPoint.y}; |
|
|
|
|
if (!Collision(originPos+move)) { |
|
|
|
|
Move(PLAYER_OBJ,move); |
|
|
|
|
return; |
|
|
|
|
} else |
|
|
|
|
if (move.x>0) { |
|
|
|
|
for (int i=0;i<wiggleRoom;i++) { //Search Up.
|
|
|
|
|
if (!Collision({originPos.x+move.x,originPos.y-i})) { |
|
|
|
|
//There is potentially to move up-right here, so we will do so.
|
|
|
|
|
Move(PLAYER_OBJ,{0,-1}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (int i=0;i<wiggleRoom;i++) { //Search Down.
|
|
|
|
|
if (!Collision({originPos.x+move.x,originPos.y+i})) { |
|
|
|
|
//There is potentially to move down-right here, so we will do so.
|
|
|
|
|
Move(PLAYER_OBJ,{0,1}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else
|
|
|
|
|
if (move.x<0) { |
|
|
|
|
for (int i=0;i<wiggleRoom;i++) { //Search Up.
|
|
|
|
|
if (!Collision({originPos.x+move.x,originPos.y-i})) { |
|
|
|
|
//There is potentially to move up-left here, so we will do so.
|
|
|
|
|
Move(PLAYER_OBJ,{0,-1}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (int i=0;i<wiggleRoom;i++) { //Search Down.
|
|
|
|
|
if (!Collision({originPos.x+move.x,originPos.y+i})) { |
|
|
|
|
//There is potentially to move down-left here, so we will do so.
|
|
|
|
|
Move(PLAYER_OBJ,{0,1}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else
|
|
|
|
|
if (move.y>0) { |
|
|
|
|
for (int i=0;i<wiggleRoom;i++) { //Search Left.
|
|
|
|
|
if (!Collision({originPos.x-i,originPos.y+move.y})) { |
|
|
|
|
//There is potentially to move down-left here, so we will do so.
|
|
|
|
|
Move(PLAYER_OBJ,{-1,0}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (int i=0;i<wiggleRoom;i++) { //Search Right.
|
|
|
|
|
if (!Collision({originPos.x+i,originPos.y+move.y})) { |
|
|
|
|
//There is potentially to move down-right here, so we will do so.
|
|
|
|
|
Move(PLAYER_OBJ,{1,0}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else
|
|
|
|
|
if (move.y<0) { |
|
|
|
|
for (int i=0;i<wiggleRoom;i++) { //Search Left.
|
|
|
|
|
if (!Collision({originPos.x-i,originPos.y+move.y})) { |
|
|
|
|
//There is potentially to move up-left here, so we will do so.
|
|
|
|
|
Move(PLAYER_OBJ,{-1,0}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (int i=0;i<wiggleRoom;i++) { //Search Right.
|
|
|
|
|
if (!Collision({originPos.x+i,originPos.y+move.y})) { |
|
|
|
|
//There is potentially to move up-right here, so we will do so.
|
|
|
|
|
Move(PLAYER_OBJ,{1,0}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AddObjectToWorld(Object*obj) { |
|
|
|
|
std::vector<Object*>::const_iterator it = OBJECTS.begin(); |
|
|
|
|
if (obj->id==PLAYER) { |
|
|
|
@ -983,6 +1047,10 @@ public: |
|
|
|
|
bool RightReleased(){ |
|
|
|
|
return GetKey(D).bReleased||GetKey(RIGHT).bReleased||GetKey(NP6).bReleased||MOUSE_RELEASED&&GetMouseX()<=128&&GetMouseX()>=96&&GetMouseY()>=HEIGHT-128; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool PlayerCanMove(){ |
|
|
|
|
return !messageBoxVisible&&PLAYER_OBJ!=nullptr; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|