This commit is contained in:
AnnaLioness 2023-11-04 20:38:51 +04:00
parent 947ef24205
commit 7770c539ae
3 changed files with 3 additions and 7 deletions

View File

@ -7,7 +7,6 @@ public class FormContainerShip{
private AbstractStrategy _abstractStrategy; private AbstractStrategy _abstractStrategy;
Canvas canv; Canvas canv;
class Canvas extends JComponent{ class Canvas extends JComponent{
public DrawingShip _drawingShip;
public Canvas(){ public Canvas(){
@ -80,7 +79,6 @@ public class FormContainerShip{
color,960, 560); color,960, 560);
_drawingShip.SetPosition(random.nextInt(10, 100),random.nextInt(10, 100)); _drawingShip.SetPosition(random.nextInt(10, 100),random.nextInt(10, 100));
canv._drawingShip = _drawingShip;
Draw(); Draw();
} }
} }
@ -104,7 +102,6 @@ public class FormContainerShip{
random.nextInt(1000, 3000),color,color2,random.nextBoolean(), random.nextBoolean(), random.nextInt(1,4),random.nextInt(1,4),960, 560); random.nextInt(1000, 3000),color,color2,random.nextBoolean(), random.nextBoolean(), random.nextInt(1,4),random.nextInt(1,4),960, 560);
_drawingShip.SetPosition(random.nextInt(10, 100),random.nextInt(10, 100)); _drawingShip.SetPosition(random.nextInt(10, 100),random.nextInt(10, 100));
canv._drawingShip = _drawingShip;
Draw(); Draw();
} }
} }

View File

@ -150,6 +150,7 @@ public class FormShipCollection {
} }
FormContainerShip form = new FormContainerShip(); FormContainerShip form = new FormContainerShip();
form._drawingShip = removedShips.peek(); form._drawingShip = removedShips.peek();
form._drawingShip.SetPosition(100, 100);
removedShips.pop(); removedShips.pop();
form.Draw(); form.Draw();
} }

View File

@ -72,18 +72,16 @@ public class ShipGenericCollection<T extends DrawingShip, U extends IMoveableObj
private void DrawObjects(Graphics2D gr) private void DrawObjects(Graphics2D gr)
{ {
int i = 0;
for (T ship: _collection.GetShips(100)) for (T ship: _collection.GetShips(100))
{ {
int i = 0;
if (ship != null) if (ship != null)
{ {
ship.SetPosition(((_collection._maxCount -i - 1) % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (_collection._maxCount - i-1) / (_pictureWidth / _placeSizeWidth) * _placeSizeHeight); ship.SetPosition(((_collection._maxCount -i - 1) % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (_collection._maxCount - i-1) / (_pictureWidth / _placeSizeWidth) * _placeSizeHeight);
ship.DrawShip(gr); ship.DrawShip(gr);
} }
i++; i++;
// TODO получение объекта
// TODO установка позиции
// TODO прорисовка объекта
} }
} }