diff --git a/AbstractMap.java b/AbstractMap.java index 4d2ba50..c5ccc9c 100644 --- a/AbstractMap.java +++ b/AbstractMap.java @@ -33,7 +33,7 @@ public abstract class AbstractMap { { for (int j = (int)(position[0] / _size_x); j <= (int)(position[1] / _size_x); ++j) { - if (_map[i][j] == _barrier) return false; + if (i >= 0 && j >= 0 && i < _map.length && j < _map[0].length && _map[i][j] == _barrier) return false; } } return true; diff --git a/DrawingShip.java b/DrawingShip.java index 442df41..8e3766c 100644 --- a/DrawingShip.java +++ b/DrawingShip.java @@ -125,6 +125,6 @@ public class DrawingShip extends JPanel { } public float[] GetCurrentPosition() { - return new float[]{_startPosX, _startPosY, _startPosX + _warmlyShipWidth, _startPosY + _warmlyShipHeight}; + return new float[]{_startPosX, _startPosX + _warmlyShipWidth, _startPosY, _startPosY + _warmlyShipHeight}; } }