From baef175283c02f32fc795083827f19f54ed345f8 Mon Sep 17 00:00:00 2001 From: bulatova_karina Date: Sat, 23 Dec 2023 23:53:49 +0300 Subject: [PATCH] full 1 laba fix --- .idea/.name | 1 + .idea/uiDesigner.xml | 124 ++++++++++++++++++++++++++++++++++++++ resources/down-arrow.png | Bin 0 -> 281 bytes resources/left-arrow.png | Bin 0 -> 265 bytes resources/right-arrow.png | Bin 0 -> 224 bytes resources/upper-arrow.png | Bin 0 -> 264 bytes src/DrawingShip.java | 120 ++++++++++++++++++++++++++++++++++++ 7 files changed, 245 insertions(+) create mode 100644 .idea/.name create mode 100644 .idea/uiDesigner.xml create mode 100644 resources/down-arrow.png create mode 100644 resources/left-arrow.png create mode 100644 resources/right-arrow.png create mode 100644 resources/upper-arrow.png create mode 100644 src/DrawingShip.java diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..002da1d --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +Main.java \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/down-arrow.png b/resources/down-arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..9d67143363585e3432a1c1d203ab1b9c01976c50 GIT binary patch literal 281 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oArNM~bhqvgQ1G;; zi(^Q|oVQcGxehr9xZG!PJ=iKPkv~* zc9Kx^`?K)}4&8QsA++)Z=NaeL@TnCH#^;@Tgv2kJgjw7>ZYuCH(qz)4*DH2Ru$Mb* cz?1ZWvE`jXwNtr}CD2<8p00i_>zopr0H3RI6#xJL literal 0 HcmV?d00001 diff --git a/resources/left-arrow.png b/resources/left-arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..046470dd1579e2ce99e38e48677f93b995460f47 GIT binary patch literal 265 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oArNM~bhqvgP;j@W zi(^Q|oVU|#xtJVz+~TLPvK|zU=>9%IR50azvg(S67o|20$2W@PT-(3ZQ}D>v**$AM z9~3wt^4`$XaKfZXmnNm`XLx_4;d#{Y1DqBNvH2B@Ar5QPm(+f2is!A77T$Nb@L`vJ z!N<1uwhtDSGR)zvNq*OSE>?;q>{)3O*9}3RhUml3c6<6X?w%M??e!!o{lH-l9p`3y z&ohn7Cq`t%+o+y0?@ZL`y>m)cVfjVm7Hdm6Pg#bRdv?g zo_d7i&cBX%-Up_*C#c3a-842yRoo=xRhZ?*{Ndc)p1PG@KZIFQcRaRubCl_?gn{+W T1E1yqUB}?*>gTe~DWM4frWsJb literal 0 HcmV?d00001 diff --git a/resources/upper-arrow.png b/resources/upper-arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..0bc323d4a84a7434e950a34a05d6b0cd4e0a1c26 GIT binary patch literal 264 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oArNM~bhqvgP;i&0 zi(^Q|oVQbbxegf!xW#)r9MrC8xaTY)c*L7CcFT3a^G|}xyX^1!D7K_1`USOA8kl%4 zuawtak|5Fc@p(wlfHmbNxVQmhc^IrFsVWmFgSL${tdEQr8i?PC!r5 z-mCYs_=f9zf$C58UcX%ZI{$%y&F{@MtaofZ#Vy%)J(#?rbq3?~4jUeUwjGSzQ!Gv{ z%T?&_jecpHJ#SL+0#A _pictureWidth){ + x = 20; + } + if (y < 0 || y + _shipHeight > _pictureHeight){ + y = 20; + } + _startPosX = x; + _startPosY = y; + } + public void MoveTransport(Direction direction){ + if (entityShip == null){ + return; + } + switch (direction){ + case Left: + System.out.println(_startPosX + " " + entityShip.GetStep() + " " + _shipWidth + " " + (_startPosX + entityShip.GetStep() + _shipWidth) + " " + _pictureWidth); + if (_startPosX - entityShip.GetStep() > 0){ + _startPosX -= (int)entityShip.GetStep(); + } + break; + case Up: + System.out.println(_startPosY + " " + entityShip.GetStep() + " " + (_startPosY + entityShip.GetStep()) + " " + _pictureHeight); + if (_startPosY - entityShip.GetStep() > 0){ + _startPosY -= (int)entityShip.GetStep(); + } + break; + case Right: + System.out.println(_startPosX + " " + entityShip.GetStep() + " " + _shipWidth + " " + (_startPosX + entityShip.GetStep() + _shipWidth) + " " + _pictureWidth); + if (_startPosX + entityShip.GetStep() + _shipWidth < _pictureWidth){ + _startPosX += (int)entityShip.GetStep(); + } + break; + case Down: + System.out.println(_startPosY + " " + entityShip.GetStep() + " " + (_startPosY + entityShip.GetStep()) + " " + _pictureHeight); + if (_startPosY + entityShip.GetStep() + _shipHeight < _pictureHeight){ + _startPosY += (int)entityShip.GetStep(); + } + break; + } + } + + public void DrawTransport(Graphics g) { + if (entityShip == null || drawingDecks == null) { + System.out.println("Error"); + return; + } + //корпус + int[] XPoints = {_startPosX, _startPosX + 180, _startPosX + 140, _startPosX + 40, _startPosX}; + int[] YPoints = {_startPosY + 110, _startPosY + 110, _startPosY + 185, _startPosY + 185, _startPosY + 110}; + + int nPoints = 5; + g.setColor(entityShip.GetBodyColor()); + g.fillPolygon(XPoints, YPoints, nPoints); + g.setColor(Color.black); + g.drawPolygon(XPoints, YPoints, nPoints); + + //якорь + g.drawLine(_startPosX + 50, _startPosY + 130, _startPosX + 50, _startPosY + 150); + g.drawLine(_startPosX + 40, _startPosY + 140, _startPosX + 60, _startPosY + 140); + g.drawLine(_startPosX + 45, _startPosY + 150, _startPosX + 55, _startPosY + 150); + + //трубы + if (entityShip.GetPipes()) { + g.setColor(entityShip.GetAddColor()); + g.fillRect(_startPosX + 55, _startPosY, 25, 80); + g.fillRect(_startPosX + 90, _startPosY + 20, 25, 60); + g.setColor(Color.black); + g.drawRect(_startPosX + 55, _startPosY, 25, 80); + g.drawRect(_startPosX + 90, _startPosY + 20, 25, 60); + } + + //топливный отсек + if (entityShip.GetSection()) { + g.setColor(Color.gray); + g.fillOval(_startPosX + 130, _startPosY + 130, 20, 20); + g.setColor(Color.black); + g.drawOval(_startPosX + 130, _startPosY + 130, 20, 20); + } + + //палуба + drawingDecks.DrawingDecks(_startPosX, _startPosY, entityShip.GetBodyColor(), g); + } +} \ No newline at end of file