From a919a519677a250156ba78066289324dc996d68b Mon Sep 17 00:00:00 2001 From: marusya Date: Sat, 23 Dec 2023 12:21:29 +0400 Subject: [PATCH] main --- .idea/.name | 1 + img/arrowDown.jpg | Bin 0 -> 702 bytes img/arrowLeft.jpg | Bin 0 -> 706 bytes img/arrowRight.jpg | Bin 0 -> 702 bytes img/arrowUp.jpg | Bin 0 -> 706 bytes src/DrawingUsta.java | 230 ++++++++++++++++++++++++++++ src/DrawingWheel.java | 140 +++++++++++++++++ src/DyrectionType.java | 3 + src/EntityUsta.java | 24 +++ src/Main.java | 7 +- src/MainFrameUsta.java | 18 +++ src/SelfPropelledArtilleryUnit.form | 96 ++++++++++++ src/SelfPropelledArtilleryUnit.java | 78 ++++++++++ src/WheelsCount.java | 7 + 14 files changed, 601 insertions(+), 3 deletions(-) create mode 100644 .idea/.name create mode 100644 img/arrowDown.jpg create mode 100644 img/arrowLeft.jpg create mode 100644 img/arrowRight.jpg create mode 100644 img/arrowUp.jpg create mode 100644 src/DrawingUsta.java create mode 100644 src/DrawingWheel.java create mode 100644 src/DyrectionType.java create mode 100644 src/EntityUsta.java create mode 100644 src/MainFrameUsta.java create mode 100644 src/SelfPropelledArtilleryUnit.form create mode 100644 src/SelfPropelledArtilleryUnit.java create mode 100644 src/WheelsCount.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/img/arrowDown.jpg b/img/arrowDown.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2d41e934bd5fb7cb8c8714d8dc7db3f6fbb203db GIT binary patch literal 702 zcmex=kSFKvnvHC#j1O51viho)>VwJvM^~|F+7hZR9eClQsBo=7c zWAL{6s$lA@$_Gtm>R(kRZR~X|o+u(wA@S_*sjY0B3%{q8-tfqHdSS|qsYllpoVMB? z+4iQ6;pvnw3Tp1!UG1-p>NBKex|QpqdWv>mbuxau`-D92j;G9Jd9}6MZSu(>GMy6LE_*g9V zUH_eYL@u;+PHDE+Te+h@uAErIVfNcI`&IwNlP0|{jeL#YY*@A9R=-upr{_tcUe~vO zUN+N5{6VN1hjZbp`rz$s2XB9kbE;{+dck^I9>avK=XP@3SgWz?zDr8rhFP~R-8g3Q i`_gS;d$-q*fB$E25x-z@)st)O0Sk792QvKsZvp@o0^z^_ literal 0 HcmV?d00001 diff --git a/img/arrowLeft.jpg b/img/arrowLeft.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5f03da1e254208cb67698990b3e6146f3b2c352b GIT binary patch literal 706 zcmex=X_-jEpc@CT5UB85uZ)ggFI8M8$xLL=dtt zRUlD8xE{FZEe0NDMxe#af(-Ty?;ktt+OoE5(}ZTbTj8NI8J52`TQ~pmM6bADQ`7Bb zbC|f^M=VLuSeG^@(D8{*kz@m(?URUO&MJ@2t<~0XVNHoJi25zWeq>@9|D7_w=5O~x zKK-0M@jH+0tFsU6HgP{m_|e@_{Mw3*udz5MDj>^g&8EEBzTbalosv87SaageKg%`$ zeB0vL6SU;tBnD&O2Z3t*jR^urk6&=oc`k9n;iv1i^E#_feXf0SaGfvjt=NjWGKcd+ zx)`QCTR0(`=f`YS{e@l&GVY}E)i3GU;=*&jw`Xa^w=xmlphJhN%I0smU6!A>@cw^> z2`U%A-ri=)HAVCfK{(3EuKTo_!! z)+Fhtc+}Eul^&ap@l4QOGIi&SGSQuGGlJDEo=5EZJoSn8 z4KBteC*_`y2@BPvrYvO+Ywe7Svs_zYclA`_*6o~+FL|x!4bACPO3hz?#cH12sh<7) mva3RmeQxOIh;wh`WN>WhZok^{YLn<=hYViE1t#+UZvp^{OyCXx literal 0 HcmV?d00001 diff --git a/img/arrowRight.jpg b/img/arrowRight.jpg new file mode 100644 index 0000000000000000000000000000000000000000..41134aa26e21aa8247198a4d35962be34118bae3 GIT binary patch literal 702 zcmex=WICV(Up}Vflj8 zU1}Uok*Ag2BGL<)w`tn_ONm_Uwrch5H+puA2P`~9{IV+J4(kre4==iRrYqFDn?bH zZBtDLkGE zQ1R6K=J#&u-uY$Bi??sM)g9|`XS(B$!;W2|6H}(LDPL18>S>$9GSlz0`kym_PVvbB z&e}^RxlL*jG00di{KxN(G<*KlGT|GxvCMlm7qGOhD?Q8qrL)qEh$r6{} gd*}H4b9;UL_rD|J4=k>FvaLN}!OrkNhX4Of0J5yy$p8QV literal 0 HcmV?d00001 diff --git a/img/arrowUp.jpg b/img/arrowUp.jpg new file mode 100644 index 0000000000000000000000000000000000000000..74ea15e1491c7584847014bff2d4997206cf343d GIT binary patch literal 706 zcmex=P*_A%OcAI`1R)JG z10*VlY9vtV|1Aa{W=5dJ%z_N|4DTO1?Ao%nYtw{gyIbL*GZ~h@He1hsd7@Wbu&L?x zN~-&SE<*2Ec?4RS9j(a z4Ncy?KGHs=(n_tZE4{>TdOPW7zx5JRHu=nz!>B&xSpUuQi5iEFx;8Isn&R;*`@~AA znUkEp?)W!xo7J_jD7UIxdx}^~CT%wsT9)2xsdsR>%xm$uqD@>`<;Q%41ZA95m4yj}wwi>q=v>`K#q{7Dr(VRJ^p z`M&J$7wYG(nk~%s(LGZA{r;vf*58{-VM8QluF1G-N1ieR7Z1-L+`_VsfYlZUN#g`Wyn>L}(Ic!UVWw^r$nW-N|nvDEE kGxcbOEK#%AnykoO&|_K^lQ2Kmj_Gg)FXI9ew&wpg0f?>D%m4rY literal 0 HcmV?d00001 diff --git a/src/DrawingUsta.java b/src/DrawingUsta.java new file mode 100644 index 0000000..1d90345 --- /dev/null +++ b/src/DrawingUsta.java @@ -0,0 +1,230 @@ +import java.awt.*; +import java.awt.geom.Path2D; +import java.awt.geom.Arc2D; +public class DrawingUsta { + public EntityUsta EntityUsta; + private DrawingWheel _drawingWheel; + private int _pictureWidth; + private int _pictureHeight; + private int _startPosX; + private int _startPosY; + private final int _ustaWidth = 170; + private final int _ustaHeight = 90; + + public boolean Init(int speed, double weight, Color bodyColor, Color additionalColor, + boolean bodyKit, boolean pushka, int width, int height) + { + + if (width < _ustaWidth || height < _ustaHeight) + { + return false; + } + _pictureWidth = width; + _pictureHeight = height; + EntityUsta = new EntityUsta(); + _drawingWheel = new DrawingWheel(); + EntityUsta.Init(speed, weight, bodyColor, additionalColor, bodyKit, pushka); + return true; + } + + public void SetWheelsCount(int weelsCount) { + + _drawingWheel.SetWheelsCount(weelsCount); + } + + public void SetPosition(int x, int y) + { + if (x < 0 || x + _ustaWidth > _pictureWidth) + { + x = 20; + } + if (y < 0 || y + _ustaHeight > _pictureHeight) + { + y = 20; + } + _startPosX = x; + _startPosY = y; + } + + public void MoveTransport(DyrectionType direction){ + if(EntityUsta == null) return; + switch(direction) + { + case Up -> { + if(_startPosY - EntityUsta.Step() >= 5) + _startPosY -= (int) EntityUsta.Step(); + } + case Down -> { + if(_startPosY + EntityUsta.Step() + _ustaHeight <= _pictureHeight) + _startPosY += (int) EntityUsta.Step(); + } + case Left -> { + if(_startPosX - EntityUsta.Step() >= 0) + _startPosX -= (int) EntityUsta.Step(); + } + case Right -> { + if(_startPosX + EntityUsta.Step() + _ustaWidth <= _pictureWidth) + _startPosX += (int) EntityUsta.Step(); + } + } + } + public void DrawTransport(Graphics2D g) { + if (EntityUsta == null) { + return; + } + + + + Color bodyColor = EntityUsta.BodyColor; + Color additionalColor = EntityUsta.AdditionalColor; + + Color blackBrush = Color.BLACK; + + Color color1 = new Color(65, 72, 51); + Color color2 = new Color(47, 69, 56); + + int cornerRadius1 = 12; + + _drawingWheel.DrawWheels(g, additionalColor, _startPosX, _startPosY); + + g.setColor(color1); + g.fillRect(_startPosX + 45, _startPosY + 20, 40, 20); + g.setColor(Color.BLACK); + g.drawRect(_startPosX + 45, _startPosY + 20, 40, 20); + + + + g.setColor(color1); + + g.fillRect(_startPosX + 10, _startPosY + 40, 120, 10); + + g.setColor(Color.BLACK); + g.drawRect(_startPosX + 10, _startPosY + 40, 120, 10); + if(EntityUsta.BodyKit) + { + Path2D path1 = new Path2D.Double(); + path1.moveTo(_startPosX + 15, _startPosY + 40); + path1.lineTo(_startPosX + 15, _startPosY + 30); + path1.lineTo(_startPosX + 15, _startPosY + 35); + path1.lineTo(_startPosX + 25, _startPosY + 35); + path1.lineTo(_startPosX + 30, _startPosY + 30); + path1.lineTo(_startPosX + 35, _startPosY + 40); + path1.closePath(); + + g.setColor(Color.BLACK); + + g.draw(path1); + + g.setColor(color2); + g.fill(path1); + + Path2D path2 = new Path2D.Double(); + path2.moveTo(_startPosX + 15, _startPosY + 30); + path2.lineTo(_startPosX + 40, _startPosY + 20); + path2.lineTo(_startPosX + 40, _startPosY + 25); + path2.lineTo(_startPosX + 25, _startPosY + 35); + path2.closePath(); + + g.setColor(Color.BLACK); + g.draw(path2); + + g.setColor(additionalColor); + g.fill(path2); + + Path2D path3 = new Path2D.Double(); + path3.moveTo(_startPosX + 10, _startPosY + 32); + path3.lineTo(_startPosX, _startPosY + 10); + path3.lineTo(_startPosX + 40, _startPosY - 7); + path3.lineTo(_startPosX + 50, _startPosY + 16); + path3.closePath(); + + g.setColor(Color.BLACK); + g.draw(path3); + + g.setColor(bodyColor); + g.fill(path3); + + Path2D path4 = new Path2D.Double(); + path4.moveTo(_startPosX, _startPosY + 10); + path4.lineTo(_startPosX + 40, _startPosY - 7); + path4.lineTo(_startPosX + 43, _startPosY - 5); + path4.lineTo(_startPosX + 41, _startPosY - 3); + path4.lineTo(_startPosX + 2, _startPosY + 13); + path4.closePath(); + + g.setColor(Color.BLACK); + + g.draw(path4); + + g.setColor(additionalColor); + g.fill(path4); + + Path2D path5 = new Path2D.Double(); + path5.moveTo(_startPosX + 3, _startPosY + 15); + path5.lineTo(_startPosX + 45, _startPosY - 2); + path5.lineTo(_startPosX + 46, _startPosY - 2); + path5.lineTo(_startPosX + 49, _startPosY - 1); + path5.lineTo(_startPosX + 46, _startPosY + 3); + path5.lineTo(_startPosX + 6, _startPosY + 20); + path5.closePath(); + + g.setColor(Color.BLACK); + + g.draw(path5); + + g.setColor(bodyColor); + g.fill(path5); + + Path2D path6 = new Path2D.Double(); + path6.moveTo(_startPosX + 5, _startPosY + 22); + path6.lineTo(_startPosX + 47, _startPosY + 5); + path6.lineTo(_startPosX + 51, _startPosY + 5); + path6.lineTo(_startPosX + 53, _startPosY + 7); + path6.lineTo(_startPosX + 8, _startPosY + 25); + path6.closePath(); + + g.setColor(Color.BLACK); + + g.draw(path6); + + g.setColor(additionalColor); + g.fill(path6); + + Path2D path7 = new Path2D.Double(); + path7.moveTo(_startPosX + 7, _startPosY + 27); + path7.lineTo(_startPosX + 46, _startPosY + 11); + path7.lineTo(_startPosX + 51, _startPosY + 9); + path7.lineTo(_startPosX + 56, _startPosY + 11); + path7.lineTo(_startPosX + 10, _startPosY + 31); + path7.closePath(); + + g.setColor(Color.BLACK); + + g.draw(path7); + + g.setColor(bodyColor); + g.fill(path7); + } + + + + if(EntityUsta.Pushka) + { + g.fillRect(_startPosX + 80, _startPosY + 25, 10, 10); + + g.setColor(Color.BLACK); + g.drawRect(_startPosX + 80, _startPosY + 25, 10, 10); + g.setColor(color1); + g.fillRect(_startPosX + 90, _startPosY + 28, 40, 5); + + g.setColor(Color.BLACK); + g.drawRect(_startPosX + 90, _startPosY + 28, 40, 5); + g.setColor(additionalColor); + g.fillRect(_startPosX + 130, _startPosY + 27, 5, 7); + + g.setColor(Color.BLACK); + g.drawRect(_startPosX + 130, _startPosY + 27, 5, 7); + } + + } +} diff --git a/src/DrawingWheel.java b/src/DrawingWheel.java new file mode 100644 index 0000000..d76ff04 --- /dev/null +++ b/src/DrawingWheel.java @@ -0,0 +1,140 @@ +import java.awt.*; +import java.awt.geom.Arc2D; +import java.awt.geom.Path2D; + +public class DrawingWheel { + private WheelsCount _wheelsCount; + public void SetWheelsCount(int enginesCount) { + for (WheelsCount val : WheelsCount.values()) { + if (val.count == enginesCount) { + this._wheelsCount = val; + return; + } + } + } + + public void DrawWheels(Graphics2D g, Color color, int startPosX, int startPosY) { + if (_wheelsCount == null) { + return; + } + + int cornerRadius1 = 12; + Color color1 = new Color(65, 72, 51); + + if (_wheelsCount.count >= _wheelsCount.Four.count) { + + Path2D path = new Path2D.Double(); + + path.append(new Arc2D.Double(startPosX + 5, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 180, 90, Arc2D.OPEN), true); + + path.append(new Arc2D.Double(startPosX + 110, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 270, 90, Arc2D.OPEN), true); + + path.append(new Arc2D.Double(startPosX + 110, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 0, 90, Arc2D.OPEN), true); + + path.append(new Arc2D.Double(startPosX + 5, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 90, 90, Arc2D.OPEN), true); + path.closePath(); + + g.setColor(color1); + + g.fill(path); + g.setColor(Color.BLACK); + g.draw(path); + + + /* наверху гусеницы*/ + g.fillOval(startPosX + 47, startPosY + 44, 13, 13); + g.fillOval(startPosX + 62, startPosY + 44, 13, 13); + g.fillOval(startPosX + 77, startPosY + 44, 13, 13); + + /* по середине гусеницы*/ + g.drawOval(startPosX + 40, startPosY + 59, 13, 13); + g.drawOval(startPosX + 55, startPosY + 59, 13, 13); + g.drawOval(startPosX + 70, startPosY + 59, 13, 13); + g.drawOval(startPosX + 85, startPosY + 59, 13, 13); + + + /* два крайних на гусенице*/ + g.fillOval(startPosX + 10, startPosY + 50, 25, 25); + g.fillOval(startPosX + 105, startPosY + 50, 25, 25); + + } + + if (_wheelsCount.count >= _wheelsCount.Five.count) { + Path2D path = new Path2D.Double(); + + path.append(new Arc2D.Double(startPosX + 5, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 180, 90, Arc2D.OPEN), true); + + path.append(new Arc2D.Double(startPosX + 125, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 270, 90, Arc2D.OPEN), true); + + path.append(new Arc2D.Double(startPosX + 125, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 0, 90, Arc2D.OPEN), true); + + path.append(new Arc2D.Double(startPosX + 5, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 90, 90, Arc2D.OPEN), true); + path.closePath(); + + g.setColor(color1); + + g.fill(path); + g.setColor(Color.BLACK); + g.draw(path); + + + /* наверху гусеницы*/ + g.fillOval(startPosX + 47, startPosY + 44, 13, 13); + g.fillOval(startPosX + 62, startPosY + 44, 13, 13); + g.fillOval(startPosX + 77, startPosY + 44, 13, 13); + g.fillOval(startPosX + 92, startPosY + 44, 13, 13); + + /* по середине гусеницы*/ + g.drawOval(startPosX + 40, startPosY + 59, 13, 13); + g.drawOval(startPosX + 55, startPosY + 59, 13, 13); + g.drawOval(startPosX + 70, startPosY + 59, 13, 13); + g.drawOval(startPosX + 85, startPosY + 59, 13, 13); + g.drawOval(startPosX + 100, startPosY + 59, 13, 13); + + + /* два крайних на гусенице*/ + g.fillOval(startPosX + 10, startPosY + 50, 25, 25); + g.fillOval(startPosX + 120, startPosY + 50, 25, 25); + } + + if (_wheelsCount.count >= _wheelsCount.Six.count) { + Path2D path = new Path2D.Double(); + + path.append(new Arc2D.Double(startPosX + 5, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 180, 90, Arc2D.OPEN), true); + + path.append(new Arc2D.Double(startPosX + 140, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 270, 90, Arc2D.OPEN), true); + + path.append(new Arc2D.Double(startPosX + 140, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 0, 90, Arc2D.OPEN), true); + + path.append(new Arc2D.Double(startPosX + 5, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 90, 90, Arc2D.OPEN), true); + path.closePath(); + + g.setColor(color1); + + g.fill(path); + g.setColor(Color.BLACK); + g.draw(path); + + + /* наверху гусеницы*/ + g.fillOval(startPosX + 47, startPosY + 44, 13, 13); + g.fillOval(startPosX + 62, startPosY + 44, 13, 13); + g.fillOval(startPosX + 77, startPosY + 44, 13, 13); + g.fillOval(startPosX + 92, startPosY + 44, 13, 13); + g.fillOval(startPosX + 107, startPosY + 44, 13, 13); + + /* по середине гусеницы*/ + g.drawOval(startPosX + 40, startPosY + 59, 13, 13); + g.drawOval(startPosX + 55, startPosY + 59, 13, 13); + g.drawOval(startPosX + 70, startPosY + 59, 13, 13); + g.drawOval(startPosX + 85, startPosY + 59, 13, 13); + g.drawOval(startPosX + 100, startPosY + 59, 13, 13); + g.drawOval(startPosX + 115, startPosY + 59, 13, 13); + + + /* два крайних на гусенице*/ + g.fillOval(startPosX + 10, startPosY + 50, 25, 25); + g.fillOval(startPosX + 135, startPosY + 50, 25, 25); + } + } +} diff --git a/src/DyrectionType.java b/src/DyrectionType.java new file mode 100644 index 0000000..5cfa2a9 --- /dev/null +++ b/src/DyrectionType.java @@ -0,0 +1,3 @@ +public enum DyrectionType { + Up, Down, Left, Right +} diff --git a/src/EntityUsta.java b/src/EntityUsta.java new file mode 100644 index 0000000..72ce791 --- /dev/null +++ b/src/EntityUsta.java @@ -0,0 +1,24 @@ +import java.awt.*; + +public class EntityUsta { + public int Speed; + public double Weight; + public Color BodyColor; + public Color AdditionalColor; + public boolean BodyKit; + public boolean Pushka; + public double Step() + { + return (double) Speed * 100 / Weight; + } + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, + boolean bodyKit, boolean pushka) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + BodyKit = bodyKit; + Pushka = pushka; + } +} diff --git a/src/Main.java b/src/Main.java index 3e59c38..6ba7eab 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,5 +1,6 @@ public class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); + public static void main(String[] args) + { + MainFrameUsta mainFrameUsta = new MainFrameUsta(); } -} \ No newline at end of file +} diff --git a/src/MainFrameUsta.java b/src/MainFrameUsta.java new file mode 100644 index 0000000..902c4bd --- /dev/null +++ b/src/MainFrameUsta.java @@ -0,0 +1,18 @@ +import javax.swing.*; + +public class MainFrameUsta extends JFrame { + private SelfPropelledArtilleryUnit _formUsta; + + public MainFrameUsta() { + super(); + setTitle("ArtilleryUnit"); + setDefaultCloseOperation(EXIT_ON_CLOSE); + _formUsta = new SelfPropelledArtilleryUnit(); + setContentPane(_formUsta.getPictureBox()); + setDefaultLookAndFeelDecorated(false); + setLocation(500, 50); + setSize(500, 850); + pack(); + setVisible(true); + } +} diff --git a/src/SelfPropelledArtilleryUnit.form b/src/SelfPropelledArtilleryUnit.form new file mode 100644 index 0000000..16c6120 --- /dev/null +++ b/src/SelfPropelledArtilleryUnit.form @@ -0,0 +1,96 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SelfPropelledArtilleryUnit.java b/src/SelfPropelledArtilleryUnit.java new file mode 100644 index 0000000..62bd8c7 --- /dev/null +++ b/src/SelfPropelledArtilleryUnit.java @@ -0,0 +1,78 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionListener; +import java.util.Random; + +public class SelfPropelledArtilleryUnit { + DrawingUsta _drawingUsta = new DrawingUsta(); + private JButton buttonCreate; + private JPanel pictureBox; + private JButton buttonUp; + private JButton buttonDown; + private JButton buttonLeft; + private JButton buttonRight; + + public JPanel getPictureBox() { + return pictureBox; + } + public SelfPropelledArtilleryUnit() + { + buttonUp.setName("buttonUp"); + buttonDown.setName("buttonDown"); + buttonLeft.setName("buttonLeft"); + buttonRight.setName("buttonRight"); + + buttonCreate.addActionListener(e -> { + _drawingUsta = new DrawingUsta(); + Random random = new Random(); + + _drawingUsta.Init( + random.nextInt(100, 300), + random.nextInt(1000, 3000), + new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)), + new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)), + random.nextBoolean(), + random.nextBoolean(), + pictureBox.getWidth(), + pictureBox.getHeight() + ); + + _drawingUsta.SetWheelsCount(random.nextInt(4, 7)); + _drawingUsta.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100)); + Draw(); + }); + + ActionListener buttonMoveClickedListener = e -> { + String buttonName = ((JButton) e.getSource()).getName(); + + switch (buttonName) { + case ("buttonUp") -> { + _drawingUsta.MoveTransport(DyrectionType.Up); + } + case ("buttonDown") -> { + _drawingUsta.MoveTransport(DyrectionType.Down); + } + case ("buttonLeft") -> { + _drawingUsta.MoveTransport(DyrectionType.Left); + } + case ("buttonRight") -> { + _drawingUsta.MoveTransport(DyrectionType.Right); + } + } + Draw(); + }; + buttonUp.addActionListener(buttonMoveClickedListener); + buttonDown.addActionListener(buttonMoveClickedListener); + buttonLeft.addActionListener(buttonMoveClickedListener); + buttonRight.addActionListener(buttonMoveClickedListener); + } + public void Draw() { + if (_drawingUsta.EntityUsta == null) { + return; + } + Graphics g = pictureBox.getGraphics(); + pictureBox.paint(g); + _drawingUsta.DrawTransport((Graphics2D) g); + } + +} diff --git a/src/WheelsCount.java b/src/WheelsCount.java new file mode 100644 index 0000000..3bd85fc --- /dev/null +++ b/src/WheelsCount.java @@ -0,0 +1,7 @@ +public enum WheelsCount { + Four(4), Five(5), Six(6); + public final int count; + WheelsCount(int count) { + this.count = count; + } +}