From dd894ab3ef91dbc0127cfe2d0b11d727a645a2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=AF=D1=88=D0=B8=D0=BD?= Date: Wed, 25 Oct 2023 20:42:47 +0400 Subject: [PATCH] Lab1 Done --- .idea/.name | 1 + .idea/misc.xml | 2 +- images/down.png | Bin 0 -> 967 bytes images/left.png | Bin 0 -> 970 bytes images/right.png | Bin 0 -> 989 bytes images/up.png | Bin 0 -> 957 bytes src/DirectionType.java | 6 ++ src/DrawingAirBomber.java | 141 ++++++++++++++++++++++++++++++++++++++ src/DrawingEngines.java | 31 +++++++++ src/EngineNumber.java | 5 ++ src/EntityAirBomber.java | 39 +++++++++++ src/FrameAirBomber.java | 107 +++++++++++++++++++++++++++++ src/Main.java | 6 +- 13 files changed, 334 insertions(+), 4 deletions(-) create mode 100644 .idea/.name create mode 100644 images/down.png create mode 100644 images/left.png create mode 100644 images/right.png create mode 100644 images/up.png create mode 100644 src/DirectionType.java create mode 100644 src/DrawingAirBomber.java create mode 100644 src/DrawingEngines.java create mode 100644 src/EngineNumber.java create mode 100644 src/EntityAirBomber.java create mode 100644 src/FrameAirBomber.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/misc.xml b/.idea/misc.xml index 6f29fee..1acf042 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/images/down.png b/images/down.png new file mode 100644 index 0000000000000000000000000000000000000000..dbc917797eaa85420fad0a5871bc627318d9ac90 GIT binary patch literal 967 zcmV;&133JNP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!TmI`;#1P{PcmWHsArdPKByLzpY$PIry|u)`Mm&J0@)G8G9{XRv`m2+RK6k>G zRJ!_{?yst=K79|lxw#48@bEA^KR<`Jx3_R~bY#yS9v*C*oSY0IQjrY}4cVUK<6|4) zKRY`!pV8wb_4V~~ad9ENy}hD=7c5L2|jAk?_1)JUu;0KA*QlUS3|zXJn3_yuZI^ z2KIoSKs6w6b91x6PeA-nfeEBNmCnviEA{Q|t@&41S2dN|(b3Uiyc~cM<9n%3PfsNw zi~jz8QE}PH*?>=v>gwt&!^XzO54!U3>ZrJkm&2&2%x7edo>Fo3_4V09Rh{{Wi!wn( za+QKaL3ej|Dz5hScJmpTN5w^HeoI{N!cXG(pL$$MTpqX@ars&g?Bepk%>P7O5Q8jn zG5;nmBws8plB!l*-j=GwMR_=}i;ELex>|0ovf}a{>%E-z7{AsYJJ1Og%oG<64>_#| z#{X$xN=krCakaFxSQZG12L!|?0Tu%;l1jmTfL7pzA5q~mGUs5qot>Sqx3`zppVN^U z1S}@#{{Ft4pPw6HIkdL6%JA^8+~40D2Rh-D`0&!-+1XhWLl_wuNq~ZYrgJ-p96XOQgN|}X8ZWnFE+5Xwe>CN z($bQ>D_#pnmawpr;_~c@s{yvRx6`02D=YS_)V@q{c|Ra#1K=Ml76INv%m!b(ySp2f pmzT|_Z&~|XT>MiAn4g@SgnwJx`fMd^Sx*1}002ovPDHLkV1j!k%-sM0 literal 0 HcmV?d00001 diff --git a/images/left.png b/images/left.png new file mode 100644 index 0000000000000000000000000000000000000000..71d88ac4d55bb66b76234e4323155ed5a9e02967 GIT binary patch literal 970 zcmV;*12z1KP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!TguX2EG)?V{e5a%ID~UKIXQ73A0O`V@zGseTsTlD6oQ;bUtgbVYil!|w6<{S zWXuUaTtI@Oqa!=QJv=;^f#<-;$cPgW*VWZ!*J*9f&(F;nxZ~qvCpR}Yj&P%RcX#JB zH17KP+C4u%$K1=yiy4oNjoG3|Z*Q-0X>3`en2X3qMMZ_hp7YAe$~c!mJ+!<{Oiak; z=B9A~eej)aF{geSht0R4CNyAjax#8XFF%Faht=0cNvI*zBMZaT)s-ooot+s6rl+S% z7DXs9P|h~Q;h^WDnwlCbc|b@t7q(pp$K2eUY;0`Uy<(685VB2jS_3ghO1$2eQ2Q_d zT{QTnUIqpROfLz|-`}%OggB66AGfr$m=~G@X=-Yc`T2QSUtibfmq&ARvuI^ovFLN+ zBGihtg8GSrv=S#LU~zFV_=dkOgqOVsmX?;nN?C}{>GJY&SRpH6(Up~z@Xah`ZEY=l zBV&mU4i5DAA3&&QXJ><6Wh%F~x2)}EW@f?)SqWb)+8LOdnhGmrAuPz^{sS^TJ|0&5 zWy!H`dpFi?QIzz9=7ukumR|+(`K&?C+7S!lN>D) z?)3Du{FLdzo2gxi^!N9hUC0)W2o`g+UeDzSEqP)lO3uL?83t(LgM)*zySuCFeWItQ zNA~viO6F>B>p5DYA2yPD5xtR~3Rnn5Z}+}YU?9d%5{gL|Nyt>?Tm#hi5~A1>xE zz|dA4LeSaS`6bl)uvE5w2uy|=&usvMWFTWO^Bj3fa-gH5!xrxD?zZc+wn+{r?Y|RY zU~l>O6E0Qwk`o`Uy1F`PZEZE3{r!Eb=rpz*xklIS>pr#ug3#~?+e;@BTOi4)$5te4 siNnJ~(Jx#)L8h^V(-$|Jd_FIK0RL*(qAaB80ssI207*qoM6N<$f)uUA0ssI2 literal 0 HcmV?d00001 diff --git a/images/right.png b/images/right.png new file mode 100644 index 0000000000000000000000000000000000000000..15838e0f18f7f68b89461cdb8c1d5f756c831228 GIT binary patch literal 989 zcmV<310wv1P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!T>zCqaA(LEl024Ls`I1^0coCcc=7 zqU_0To57wRg3A6gA|vz9tjcJK6<1eR@x#MI{PFP-pPrsV8Ta(`l$YbVw6tV=A-@oJ zc6JtL?(Xj5Y&OdTg7jgv2Xl;)5J8PgodWHR=2?C$PLZ*Q;l)0Zz6E~=}m6P-zN zU{nFAudg=_IOl#02#3E-Ex zxv*m?Y-(!ClC#J9JM2^{o0*xhwwC2+31VD9>ixAh-(-T~w+uYoo`2}yM=jUf5 z{N_Lkp1EAEAL#7t3?{^8XJ^eP6bl!zbR<+CyE)X!E^#>EoclQkkUfOS$w}GR*s!W2 z6ie|ZE(0^6HUh`T#|h`sc+r-YD^v)KkB?j5cd^XMjyR;w$~s62hcs|LAvgwv0~B}Z zq+?@a#_Qc%FqYyzLJlv^G@;eMoMNx1aycC%Dcoo~Mn*1sI8S z)2+}uKR-7Ps1nl9&|t3s#T&u88tY>~ps%ECZEab*m{@Y~!{kM3BxZk|Lz;XXrXTyH zmIlSfQeb}h?}X9z+FG5ALmDJ>4r2vtYiqKwuwW+_uGrXYHY>jXfC{x_b26KQ00000 LNkvXXu0mjft4r9Z literal 0 HcmV?d00001 diff --git a/images/up.png b/images/up.png new file mode 100644 index 0000000000000000000000000000000000000000..4b79487574ee9afea12812fcf21caba8d4d640e1 GIT binary patch literal 957 zcmV;u148_XP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!T|J&;vH zv6;ztcX#y+;!67n2If8M?Ed~f4mlg|?(Y72hAl5Imx6lV+1b&%)|Brf!(=sh55KXPzMY<)Y9piXBmMCGpPiiz22A?q=BC#A zK4OQ5hYCnSU<`gslKU6TJ;tV|r-Ok)zOk{PJ!I&UAxkeVcq@v_+vMbAFhC_=UtibW z%;KU4*!cK(kT{L6t*wb8#E*XxSFu>shOx1+AYm3?TwD}aDsf?>qoYBh@A&-uyf`b0 z3mX|32@?E|&&|z!u$PI8nqz~5gTakI;WINcicu1m|K0`$27()Y(kCV+6iea)^!4=x z7ygD14-YGNZfk2R-rwK1wzf8_si`riYRlzvR#jDHP7v16&|n7#2jP02M%~$EOEPg!j_hnOy99L`t2==hlYlNrw{qm)YQkWuzB7npU<1S(9L~oIw2!- z@a5&D<1(E(t&tVxv?J{93GH`ZjxfCNM?8q4NabKLBXgeD*4Bz7i@9VGNMTp8by}i9%BXh93%|yaM(pq(OwSpqf zmX;PSC~InJQnp}t;g3#EPE^v)&Q5c`xim5dcXxM-jMJty_m@Zqh1~t-vfkcaX@v@c z;Z-}ky1G;nMAg&Nqmen-i;L2vH8RG?xV5!af+Ay*0mG||zY-Ui@?gGiX{@}*=!8I2 z4P5H+SK>+r&SJhT$-s=s!0`W?xX8+jtGT&ZrOqs_ETtwp4$7686c?F(5*H_^B(5x$ zNnF0iNZyMJ{GA^A>d@2F;sSedfqzO|<$>WZiHj1`ct+-6dW5ksttCs1xZFR5*4Wsn fQlqCo;wsuZZbKaPmNx4v00000NkvXXu0mjfQHIfw literal 0 HcmV?d00001 diff --git a/src/DirectionType.java b/src/DirectionType.java new file mode 100644 index 0000000..0d664bb --- /dev/null +++ b/src/DirectionType.java @@ -0,0 +1,6 @@ +public enum DirectionType { + UP, + DOWN, + LEFT, + RIGHT +} \ No newline at end of file diff --git a/src/DrawingAirBomber.java b/src/DrawingAirBomber.java new file mode 100644 index 0000000..5c06bf7 --- /dev/null +++ b/src/DrawingAirBomber.java @@ -0,0 +1,141 @@ +import javax.swing.*; +import java.awt.*; + +public class DrawingAirBomber extends JPanel { + private EntityAirBomber entityAirBomber; + public EntityAirBomber getEntityAirBomber(){ + return entityAirBomber; + } + private int _pictureWidth; + private int _pictureHeight; + private int _startPosX; + private int _startPosY; + private final int PLANE_WIDTH = 160; + private final int PLANE_HEIGHT = 160; + private DrawingEngines drawingEngines; + public boolean init(int speed, double weight, Color bodyColor, Color + additionalColor, boolean bombs, boolean fuel, int width, int height, int blocksNumber) + { + if (PLANE_WIDTH > width || PLANE_HEIGHT > height) + return false; + _pictureWidth = width; + _pictureHeight = height; + entityAirBomber = new EntityAirBomber(); + entityAirBomber.init(speed, weight, bodyColor, additionalColor, + bombs, fuel); + drawingEngines = new DrawingEngines(); + drawingEngines.setNumber(blocksNumber); + return true; + } + public void setPosition(int x, int y) + { + if (x < 0 || y < 0 || x + PLANE_WIDTH >= _pictureWidth || y + PLANE_HEIGHT >= _pictureHeight) + x = y = 2; + _startPosX = x; + _startPosY = y; + } + public void moveTransport(DirectionType direction) + { + if (entityAirBomber == null) + return; + switch (direction) + { + //влево + case LEFT: + if (_startPosX - entityAirBomber.step.get().intValue() > 0) + _startPosX -= entityAirBomber.step.get().intValue(); + break; + //вверх + case UP: + if (_startPosY - entityAirBomber.step.get().intValue() > 0) + _startPosY -= entityAirBomber.step.get().intValue(); + break; + // вправо + case RIGHT: + if (_startPosX + PLANE_WIDTH + entityAirBomber.step.get().intValue() < _pictureWidth) + _startPosX += entityAirBomber.step.get().intValue(); + break; + //вниз + case DOWN: + if (_startPosY + PLANE_HEIGHT + entityAirBomber.step.get().intValue() < _pictureHeight) + _startPosY += entityAirBomber.step.get().intValue(); + break; + } + } + public void drawTransport(Graphics gr) + { + super.paintComponent(gr); + Graphics2D g = (Graphics2D) gr; + if (entityAirBomber == null) + return; + BasicStroke pen = new BasicStroke(2); + Color penColor = Color.BLACK; + Color bodyColor = entityAirBomber.getBodyColor(); + Color additionalColor = entityAirBomber.getAdditionalColor(); + g.setStroke(pen); + g.setColor(bodyColor); + //фюзеляж + g.fillRect( _startPosX + 20, _startPosY + 70, 140, 20); + //кабина + int[] pointX = new int[]{ _startPosX, _startPosX+20, _startPosX+20}; + int[] pointY = new int[]{ _startPosY + 80, _startPosY+70, _startPosY+90}; + g.setColor(Color.BLUE); + g.fillPolygon(pointX, pointY, 3); + //границы самолета + g.setColor(penColor); + g.drawPolygon(pointX, pointY, 3); + g.drawRect(_startPosX + 20, _startPosY + 70, 140, 20); + //Крылья + pointX = new int[] {_startPosX+70, _startPosX+70, _startPosX + 90, _startPosX + 100}; + pointY = new int[] { _startPosY+70, _startPosY, _startPosY, _startPosY+70}; + g.setColor(bodyColor); + g.fillPolygon(pointX, pointY, 4); + g.setColor(penColor); + g.drawPolygon(pointX, pointY, 4); + pointX = new int[] {_startPosX+70, _startPosX+70, _startPosX + 90, _startPosX + 100}; + pointY = new int[] { _startPosY+90, _startPosY+160, _startPosY+160, _startPosY+90}; + g.setColor(bodyColor); + g.fillPolygon(pointX, pointY, 4); + g.setColor(penColor); + g.drawPolygon(pointX, pointY, 4); + pointX = new int[] {_startPosX+130, _startPosX+130, _startPosX + 160, _startPosX + 160}; + pointY = new int[] { _startPosY+70, _startPosY+50, _startPosY+30, _startPosY+70}; + g.setColor(bodyColor); + g.fillPolygon(pointX, pointY, 4); + g.setColor(penColor); + g.drawPolygon(pointX, pointY, 4); + pointX = new int[] {_startPosX+130, _startPosX+130, _startPosX + 160, _startPosX + 160}; + pointY = new int[] { _startPosY+90, _startPosY+110, _startPosY+130, _startPosY+90}; + g.setColor(bodyColor); + g.fillPolygon(pointX, pointY, 4); + g.setColor(penColor); + g.drawPolygon(pointX, pointY, 4); + // топливо + if (entityAirBomber.getFuel()) + { + g.setColor(additionalColor); + g.fillOval(_startPosX + 60, _startPosY - 1, 40, 10); + g.fillOval(_startPosX + 60, _startPosY + 150, 40, 10); + g.setColor(penColor); + g.drawOval(_startPosX + 60, _startPosY - 1, 40, 10); + g.drawOval(_startPosX + 60, _startPosY + 150, 40, 10); + } + //бомбы + if (entityAirBomber.getBombs()) + { + pointX = new int[]{_startPosX+50, _startPosX+70, _startPosX+80, _startPosX+90, _startPosX+90, _startPosX+80, _startPosX+70, _startPosX+50}; + pointY = new int[]{_startPosY+75, _startPosY+75, _startPosY+80, _startPosY+75, _startPosY+85, _startPosY+80, _startPosY+85, _startPosY+85}; + g.setColor(additionalColor); + g.fillPolygon(pointX, pointY, 8); + g.setColor(penColor); + g.drawPolygon(pointX, pointY, 8); + pointX = new int[]{_startPosX+100, _startPosX+120, _startPosX+130, _startPosX+140, _startPosX+140, _startPosX+130, _startPosX+120, _startPosX+100}; + pointY = new int[]{_startPosY+75, _startPosY+75, _startPosY+80, _startPosY+75, _startPosY+85, _startPosY+80, _startPosY+85, _startPosY+85}; + g.setColor(additionalColor); + g.fillPolygon(pointX, pointY, 8); + g.setColor(penColor); + g.drawPolygon(pointX, pointY,8); + } + drawingEngines.drawBlocks(g, _startPosX, _startPosY); + } +} \ No newline at end of file diff --git a/src/DrawingEngines.java b/src/DrawingEngines.java new file mode 100644 index 0000000..51366dc --- /dev/null +++ b/src/DrawingEngines.java @@ -0,0 +1,31 @@ +import java.awt.*; + +public class DrawingEngines { + private EngineNumber number; + public void setNumber(int x){ + if(x <= 2) + number = EngineNumber.TWO; + if(x == 4) + number = EngineNumber.FOUR; + if(x >= 6) + number = EngineNumber.SIX; + } + public void drawBlocks(Graphics2D graphics2D, int _startX, int _startY){ + graphics2D.fillRect(_startX+70, _startY+20, 20, 15); + graphics2D.fillOval(_startX+80, _startY+20, 20, 15); + graphics2D.fillRect(_startX+70, _startY+125, 20, 15); + graphics2D.fillOval(_startX+80, _startY+125, 20, 15); + if (number == EngineNumber.FOUR || number == EngineNumber.SIX){ + graphics2D.fillRect(_startX+70, _startY+40, 20, 15); + graphics2D.fillOval(_startX+80, _startY+40, 20, 15); + graphics2D.fillRect(_startX+70, _startY+105, 20, 15); + graphics2D.fillOval(_startX+80, _startY+105, 20, 15); + } + if (number == EngineNumber.SIX){ + graphics2D.fillRect(_startX+130, _startY+50, 25, 15); + graphics2D.fillOval(_startX+145, _startY+50, 20, 15); + graphics2D.fillRect(_startX+130, _startY+95, 25, 15); + graphics2D.fillOval(_startX+145, _startY+95, 20, 15); + } + } +} \ No newline at end of file diff --git a/src/EngineNumber.java b/src/EngineNumber.java new file mode 100644 index 0000000..dea68cb --- /dev/null +++ b/src/EngineNumber.java @@ -0,0 +1,5 @@ +public enum EngineNumber { + TWO, + FOUR, + SIX +} \ No newline at end of file diff --git a/src/EntityAirBomber.java b/src/EntityAirBomber.java new file mode 100644 index 0000000..b4d7405 --- /dev/null +++ b/src/EntityAirBomber.java @@ -0,0 +1,39 @@ +import java.awt.*; +import java.util.function.Supplier; + +public class EntityAirBomber { + private int speed; + public int getSpeed(){ + return speed; + } + private double weight; + public double getWeight(){ + return weight; + } + private Color bodyColor; + public Color getBodyColor(){ + return bodyColor; + } + private Color additionalColor; + public Color getAdditionalColor(){ + return additionalColor; + } + private boolean isFuel; + public boolean getFuel() { + return isFuel; + } + private boolean isBombs; + public boolean getBombs() { + return isBombs; + } + public Supplier step = () -> (double) speed * 100 / weight; + public void init(int speed, double weight, Color bodyColor, Color + additionalColor, boolean isFuel, boolean isBombs) { + this.speed = speed; + this.weight = weight; + this.bodyColor = bodyColor; + this.additionalColor = additionalColor; + this.isFuel = isFuel; + this.isBombs = isBombs; + } +} \ No newline at end of file diff --git a/src/FrameAirBomber.java b/src/FrameAirBomber.java new file mode 100644 index 0000000..bfe2a19 --- /dev/null +++ b/src/FrameAirBomber.java @@ -0,0 +1,107 @@ +import javax.imageio.ImageIO; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.io.File; +import java.io.IOException; +import java.util.Random; +public class FrameAirBomber extends JFrame { + private DrawingAirBomber drawingAirBomber; + private final JComponent pictureBox; + public FrameAirBomber() throws IOException { + super("Бомбардировщик"); + setSize(new Dimension(900,500)); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + //components initialisation + pictureBox = new JComponent(){ + public void paintComponent(Graphics graphics){ + super.paintComponent(graphics); + Graphics2D graphics2D = (Graphics2D) graphics; + if (drawingAirBomber != null) drawingAirBomber.drawTransport(graphics2D); + super.repaint(); + } + }; + JButton createButton = new JButton("Создать"); + JButton rightButton = new JButton(new ImageIcon(ImageIO.read(new File("images/right.png")))); + JButton leftButton = new JButton(new ImageIcon(ImageIO.read(new File("images/left.png")))); + JButton upButton = new JButton(new ImageIcon(ImageIO.read(new File("images/up.png")))); + JButton downButton = new JButton(new ImageIcon(ImageIO.read(new File("images/down.png")))); + pictureBox.setBounds( 0, 0, getContentPane().getWidth(), getContentPane().getHeight()); + //ActionListeners and ActionCommand addition + createButton.addActionListener(e -> buttonCreateClick()); + rightButton.setActionCommand("right"); + rightButton.addActionListener(this::buttonMoveClick); + leftButton.setActionCommand("left"); + leftButton.addActionListener(this::buttonMoveClick); + upButton.setActionCommand("up"); + upButton.addActionListener(this::buttonMoveClick); + downButton.setActionCommand("down"); + downButton.addActionListener(this::buttonMoveClick); + //component addition + setLayout(new BorderLayout()); + JPanel panelBattleship = new JPanel(new BorderLayout()); + JPanel createPanel = new JPanel(new BorderLayout()); + createPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); + createPanel.add(createButton, BorderLayout.SOUTH); + JPanel movementPanel = new JPanel(new GridBagLayout()); + JPanel rightPanel = new JPanel(new BorderLayout()); + rightPanel.add(movementPanel, BorderLayout.SOUTH); + rightButton.setPreferredSize(new Dimension(30,30)); + GridBagConstraints constraints = new GridBagConstraints(); + constraints.gridx = 2; + constraints.gridy = 1; + constraints.insets.left = constraints.insets.top = constraints.insets.bottom = constraints.insets.right = 2; + movementPanel.add(rightButton, constraints); + leftButton.setPreferredSize(new Dimension(30,30)); + constraints.gridx = 0; + constraints.gridy = 1; + movementPanel.add(leftButton, constraints); + upButton.setPreferredSize(new Dimension(30,30)); + constraints.gridx = 1; + constraints.gridy = 0; + movementPanel.add(upButton, constraints); + downButton.setPreferredSize(new Dimension(30,30)); + constraints.gridx = 1; + constraints.gridy = 1; + movementPanel.add(downButton, constraints); + add(pictureBox); + panelBattleship.add(rightPanel, BorderLayout.EAST); + panelBattleship.add(createPanel, BorderLayout.WEST); + add(panelBattleship,BorderLayout.CENTER); + setVisible(true); + } + private void buttonCreateClick() { + Random random = new Random(); + drawingAirBomber = new DrawingAirBomber(); + pictureBox.setBounds(0,0,getContentPane().getWidth(),getContentPane().getHeight()); + drawingAirBomber.init(random.nextInt(200) + 100, random.nextInt(2000) + 1000, 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(), (random.nextInt(3)+1)*2); + drawingAirBomber.setPosition(random.nextInt(90) + 10, random.nextInt(90) + 10); + draw(); + } + private void buttonMoveClick(ActionEvent event) { + if(drawingAirBomber == null || drawingAirBomber.getEntityAirBomber() == null) + return; + switch (event.getActionCommand()) + { + case "left": + drawingAirBomber.moveTransport(DirectionType.LEFT); + break; + case "right": + drawingAirBomber.moveTransport(DirectionType.RIGHT); + break; + case "up": + drawingAirBomber.moveTransport(DirectionType.UP); + break; + case "down": + drawingAirBomber.moveTransport(DirectionType.DOWN); + break; + } + draw(); + } + private void draw() { + if (drawingAirBomber == null) + return; + pictureBox.repaint(); + } +} \ No newline at end of file diff --git a/src/Main.java b/src/Main.java index db0fcda..b191374 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,5 +1,5 @@ -public class Main { - public static void main(String[] args){ +import java.io.IOException; - } +public class Main { + public static void main(String[] args) throws IOException { new FrameAirBomber(); } }