Доработанная
This commit is contained in:
parent
973cec8de7
commit
34e21f2507
@ -29,18 +29,16 @@ public abstract class AbstractMap {
|
||||
|
||||
public BufferedImage MoveObject(Direction direction)
|
||||
{
|
||||
if (_drawingObject != null)
|
||||
{
|
||||
if (true)
|
||||
{
|
||||
_drawingObject.MoveObject(direction);
|
||||
}
|
||||
if(_drawingObject!=null){
|
||||
float[] cortege = _drawingObject.GetCurrentPosition();
|
||||
if (Check(cortege[0],cortege[1],cortege[2],cortege[3])!= 0)
|
||||
if (Check(cortege[0],cortege[1],cortege[2],cortege[3]) != 0)
|
||||
{
|
||||
_drawingObject.MoveObject(GetOpositDirection(direction));
|
||||
}
|
||||
return DrawMapWithObject();
|
||||
if(true){
|
||||
_drawingObject.MoveObject(direction);
|
||||
}
|
||||
return DrawMapWithObject();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -73,28 +71,25 @@ public abstract class AbstractMap {
|
||||
int y = _random.nextInt(0, 10);
|
||||
_drawingObject.SetObject(x, y, _width, _height);
|
||||
float[] cortege = _drawingObject.GetCurrentPosition();
|
||||
float nowX = cortege[0];
|
||||
float nowY = cortege[1];
|
||||
float lenX = cortege[2]-cortege[0];
|
||||
float lenY = cortege[3] - cortege[1];
|
||||
while (Check(nowX, nowY, nowX + lenX, nowY + lenY) != 2)
|
||||
|
||||
while (Check(cortege[0], cortege[1], cortege[2], cortege[3]) != 2)
|
||||
{
|
||||
int result;
|
||||
do
|
||||
{
|
||||
result = Check(nowX, nowY, nowX + lenX, nowY + lenY);
|
||||
result = Check(cortege[0], cortege[1], cortege[2], cortege[3]);
|
||||
if (result == 0)
|
||||
{
|
||||
_drawingObject.SetObject((int)nowX, (int)nowY, _width, _height);
|
||||
_drawingObject.SetObject((int)cortege[0], (int)cortege[1], _width, _height);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
nowX += _size_x;
|
||||
cortege[0] += _size_x;
|
||||
}
|
||||
} while (result != 2);
|
||||
nowX = x;
|
||||
nowY += _size_y;
|
||||
cortege[0] = x;
|
||||
cortege[1] += _size_y;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class DrawingMap extends JPanel{
|
||||
Map.toolBarLabelWieght.setText("Weight: " + warship.GetWarship().GetWeight() + " ");
|
||||
Map.toolBarLabelColor.setText("Color: " + warship.GetWarship().GetBodyColor().getRed() + " " +
|
||||
warship.GetWarship().GetBodyColor().getGreen() + " " + warship.GetWarship().GetBodyColor().getBlue());
|
||||
bufferedImage = _abstractMap.CreateMap(700,550,new DrawingObjectWarship(warship));
|
||||
bufferedImage = _abstractMap.CreateMap(900,550,new DrawingObjectWarship(warship));
|
||||
}
|
||||
//Создание обычного корабля
|
||||
public void CreateButtonAction(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user