Fix distance checking for object interactions. Fixed smooth move controls bug

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent adb5d9aceb
commit 395fe517b6
  1. BIN
      C++ProjectTemplate
  2. 2
      main.cpp
  3. 22
      object.h

Binary file not shown.

@ -1969,7 +1969,7 @@ void SeasonI::keyUpdates() {
goto next;
}
} //Make sure it's not a party member.
dist = abs(PARTY_MEMBER_OBJ[0]->GetPos().x-OBJECTS[i]->GetPos().x)+abs(PARTY_MEMBER_OBJ[0]->GetPos().y-OBJECTS[i]->GetPos().y);
dist = std::abs(PARTY_MEMBER_OBJ[0]->GetPosWithOrigin().x-OBJECTS[i]->GetPosWithOrigin().x)+std::abs(PARTY_MEMBER_OBJ[0]->GetPosWithOrigin().y-OBJECTS[i]->GetPosWithOrigin().y);
if (dist<closestDist) {
closestDist=dist;
closest=OBJECTS[i];

@ -121,8 +121,8 @@ class Object{
Move({0,move.y});
return true;
}
else
if (move.x>0) {
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.
@ -152,7 +152,7 @@ class Object{
}
}
}
if (move.y>0) {
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.
@ -167,22 +167,6 @@ class Object{
return true;
}
}
} 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({-1,0});
return true;
}
}
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({1,0});
return true;
}
}
}
return false;
}

Loading…
Cancel
Save