исправил перемещение

This commit is contained in:
Макс Бондаренко 2022-11-29 22:32:20 +04:00
parent e822561eec
commit c7d2376962
2 changed files with 2 additions and 2 deletions

View File

@ -33,7 +33,7 @@ public abstract class AbstractMap {
{ {
for (int j = (int)(position[0] / _size_x); j <= (int)(position[1] / _size_x); ++j) 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; return true;

View File

@ -125,6 +125,6 @@ public class DrawingShip extends JPanel {
} }
public float[] GetCurrentPosition() { public float[] GetCurrentPosition() {
return new float[]{_startPosX, _startPosY, _startPosX + _warmlyShipWidth, _startPosY + _warmlyShipHeight}; return new float[]{_startPosX, _startPosX + _warmlyShipWidth, _startPosY, _startPosY + _warmlyShipHeight};
} }
} }