some minor fixes p.2

This commit is contained in:
Zakharov_Rostislav 2023-10-26 23:57:01 +04:00
parent 4ff33ecdf2
commit 0ea7fea345

View File

@ -14,14 +14,14 @@ public class DrawingBattleship {
private int pictureHeight;
private int startPosX;
private int startPosY;
private final int shipWidth = 150;
public int getShipWidth() {return shipWidth;}
private final int shipHeight = 50;
public int getShipHeight() {return shipHeight;}
private final int SHIP_WIDTH = 150;
public int getShipWidth() {return SHIP_WIDTH;}
private final int SHIP_HEIGHT = 50;
public int getShipHeight() {return SHIP_HEIGHT;}
private DrawingBlocks drawingBlocks;
public boolean init(int speed, double weight, Color bodyColor, Color
additionalColor, boolean turret, boolean rocketLauncher, int width, int height, int blocksNumber) {
if (width < shipWidth || height < shipHeight)
if (width < SHIP_WIDTH || height < SHIP_HEIGHT)
return false;
pictureWidth = width;
pictureHeight = height;
@ -32,7 +32,7 @@ public class DrawingBattleship {
return true;
}
public void setPosition(int x, int y) {
if (x < 0 || y < 0 || x + shipWidth > pictureWidth || y + shipHeight > pictureHeight) {
if (x < 0 || y < 0 || x + SHIP_WIDTH > pictureWidth || y + SHIP_HEIGHT > pictureHeight) {
x = 0;
y = 0;
}
@ -55,12 +55,12 @@ public class DrawingBattleship {
break;
// вправо
case RIGHT:
if (startPosX + shipWidth + entityBattleship.step.get().intValue() < pictureWidth)
if (startPosX + SHIP_WIDTH + entityBattleship.step.get().intValue() < pictureWidth)
startPosX += entityBattleship.step.get().intValue();
break;
//вниз
case DOWN:
if (startPosY + shipHeight + entityBattleship.step.get().intValue() < pictureHeight)
if (startPosY + SHIP_HEIGHT + entityBattleship.step.get().intValue() < pictureHeight)
startPosY += entityBattleship.step.get().intValue();
break;
}