some minor fixes p.2
This commit is contained in:
parent
4ff33ecdf2
commit
0ea7fea345
@ -14,14 +14,14 @@ public class DrawingBattleship {
|
|||||||
private int pictureHeight;
|
private int pictureHeight;
|
||||||
private int startPosX;
|
private int startPosX;
|
||||||
private int startPosY;
|
private int startPosY;
|
||||||
private final int shipWidth = 150;
|
private final int SHIP_WIDTH = 150;
|
||||||
public int getShipWidth() {return shipWidth;}
|
public int getShipWidth() {return SHIP_WIDTH;}
|
||||||
private final int shipHeight = 50;
|
private final int SHIP_HEIGHT = 50;
|
||||||
public int getShipHeight() {return shipHeight;}
|
public int getShipHeight() {return SHIP_HEIGHT;}
|
||||||
private DrawingBlocks drawingBlocks;
|
private DrawingBlocks drawingBlocks;
|
||||||
public boolean init(int speed, double weight, Color bodyColor, Color
|
public boolean init(int speed, double weight, Color bodyColor, Color
|
||||||
additionalColor, boolean turret, boolean rocketLauncher, int width, int height, int blocksNumber) {
|
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;
|
return false;
|
||||||
pictureWidth = width;
|
pictureWidth = width;
|
||||||
pictureHeight = height;
|
pictureHeight = height;
|
||||||
@ -32,7 +32,7 @@ public class DrawingBattleship {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public void setPosition(int x, int y) {
|
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;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
@ -55,12 +55,12 @@ public class DrawingBattleship {
|
|||||||
break;
|
break;
|
||||||
// вправо
|
// вправо
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
if (startPosX + shipWidth + entityBattleship.step.get().intValue() < pictureWidth)
|
if (startPosX + SHIP_WIDTH + entityBattleship.step.get().intValue() < pictureWidth)
|
||||||
startPosX += entityBattleship.step.get().intValue();
|
startPosX += entityBattleship.step.get().intValue();
|
||||||
break;
|
break;
|
||||||
//вниз
|
//вниз
|
||||||
case DOWN:
|
case DOWN:
|
||||||
if (startPosY + shipHeight + entityBattleship.step.get().intValue() < pictureHeight)
|
if (startPosY + SHIP_HEIGHT + entityBattleship.step.get().intValue() < pictureHeight)
|
||||||
startPosY += entityBattleship.step.get().intValue();
|
startPosY += entityBattleship.step.get().intValue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user