Commit d569ab0f authored by 9831111's avatar 9831111 🙂

Add horizontalWallCollision method.

parent 06746c8f
...@@ -112,16 +112,16 @@ public class GameState { ...@@ -112,16 +112,16 @@ public class GameState {
return null; return null;
} }
// public Wall horizontalWallCollision() { public Wall horizontalWallCollision() {
// for (Wall wall : Controller.walls) { for (Wall wall : Controller.walls) {
// if (wall.getWidth() == 50 && wall.getHeight() == 5) { if (wall.getWidth() == 50 && wall.getHeight() == 5) {
// if ((getBounds(locX, locY).intersects(new Rectangle((int) wall.getX(), (int) wall.getY(), 50, 5)))) { if ((getBounds(locX, locY).intersects(new Rectangle((int) wall.getX(), (int) wall.getY(), 50, 5)))) {
// return wall; return wall;
// } }
// } }
// } }
// return null; return null;
// } }
public boolean isMoveAllowed(int px) { public boolean isMoveAllowed(int px) {
...@@ -154,17 +154,17 @@ public class GameState { ...@@ -154,17 +154,17 @@ public class GameState {
} }
} }
// if (horizontalWallCollision() != null) { if (horizontalWallCollision() != null) {
// if (horizontalWallCollision().getY() > locY && px > 0 && ((rotateAmount <= 180 && rotateAmount >= 0) || (rotateAmount <= -180 && rotateAmount > -360))) if (horizontalWallCollision().getY() > locY && px > 0 && ((rotateAmount <= 180 && rotateAmount >= 0) || (rotateAmount <= -180 && rotateAmount > -360)))
// return false; return false;
// if (horizontalWallCollision().getY() < locY && px < 0 && ((rotateAmount <= 180 && rotateAmount >= 0) || (rotateAmount <= -180 && rotateAmount > -360))) if (horizontalWallCollision().getY() < locY && px < 0 && ((rotateAmount <= 180 && rotateAmount >= 0) || (rotateAmount <= -180 && rotateAmount > -360)))
// return false; return false;
// if (horizontalWallCollision().getY() < locY && px > 0 && ((rotateAmount >= -180 && rotateAmount <= 0) || (rotateAmount >= 180 && rotateAmount < 360))) if (horizontalWallCollision().getY() < locY && px > 0 && ((rotateAmount >= -180 && rotateAmount <= 0) || (rotateAmount >= 180 && rotateAmount < 360)))
// return false; return false;
// if (horizontalWallCollision().getY() > locY && px < 0 && ((rotateAmount >= -180 && rotateAmount <= 0) || (rotateAmount >= 180 && rotateAmount < 360))) if (horizontalWallCollision().getY() > locY && px < 0 && ((rotateAmount >= -180 && rotateAmount <= 0) || (rotateAmount >= 180 && rotateAmount < 360)))
// return false; return false;
//
// } }
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment