From be6065021e539a4d89f599c324ee085e1ef81534 Mon Sep 17 00:00:00 2001 From: olshab Date: Sun, 26 Nov 2023 16:21:53 +0400 Subject: [PATCH 1/6] Port from base project --- src/App.java | 5 - src/BomberEntity.java | 24 ++++ src/BomberForm.java | 163 ++++++++++++++++++++++++++ src/BomberRenderer.java | 214 +++++++++++++++++++++++++++++++++++ src/DirectionType.java | 7 ++ src/Program.java | 6 + src/Resources/ArrowDown.png | Bin 0 -> 557 bytes src/Resources/ArrowLeft.png | Bin 0 -> 507 bytes src/Resources/ArrowRight.png | Bin 0 -> 502 bytes src/Resources/ArrowUp.png | Bin 0 -> 539 bytes 10 files changed, 414 insertions(+), 5 deletions(-) delete mode 100644 src/App.java create mode 100644 src/BomberEntity.java create mode 100644 src/BomberForm.java create mode 100644 src/BomberRenderer.java create mode 100644 src/DirectionType.java create mode 100644 src/Program.java create mode 100644 src/Resources/ArrowDown.png create mode 100644 src/Resources/ArrowLeft.png create mode 100644 src/Resources/ArrowRight.png create mode 100644 src/Resources/ArrowUp.png diff --git a/src/App.java b/src/App.java deleted file mode 100644 index 0a839f9..0000000 --- a/src/App.java +++ /dev/null @@ -1,5 +0,0 @@ -public class App { - public static void main(String[] args) throws Exception { - System.out.println("Hello, World!"); - } -} diff --git a/src/BomberEntity.java b/src/BomberEntity.java new file mode 100644 index 0000000..5511fcb --- /dev/null +++ b/src/BomberEntity.java @@ -0,0 +1,24 @@ +import java.awt.Color; + +public class BomberEntity +{ + public int Speed; + public double Weight; + public Color BodyColor; + public Color AdditionalColor; + public boolean Bombs; + public boolean FuelTanks; + public double Step; + + public void Init(int Speed, double Weight, Color BodyColor, Color AdditionalColor, boolean FuelTanks, boolean Bombs) + { + this.Speed = Speed; + this.Weight = Weight; + this.BodyColor = BodyColor; + this.AdditionalColor = AdditionalColor; + this.FuelTanks = FuelTanks; + this.Bombs = Bombs; + + this.Step = (double)Speed * 100 / Weight * 5 / 2; + } +} diff --git a/src/BomberForm.java b/src/BomberForm.java new file mode 100644 index 0000000..8bd7cd9 --- /dev/null +++ b/src/BomberForm.java @@ -0,0 +1,163 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.image.BufferedImage; +import java.util.Random; + +public class BomberForm extends JFrame +{ + private BomberRenderer _bomberRenderer; + + public BomberForm() + { + InitializeComponent(); + } + + private void Draw() + { + BufferedImage bmp = new BufferedImage( + BomberPictureBox.getWidth(), + BomberPictureBox.getHeight(), + BufferedImage.TYPE_INT_ARGB + ); + Graphics2D g = bmp.createGraphics(); + _bomberRenderer.DrawEntity(g); + + BomberPictureBox.setIcon(new ImageIcon(bmp)); + } + + private void ButtonCreate_Click(ActionEvent e) + { + Random random = new Random(); + _bomberRenderer = new BomberRenderer(); + + _bomberRenderer.Init( + random.nextInt(100, 300), + random.nextInt(1000, 3000), + new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)), + new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)), + true, + true, + BomberPictureBox.getWidth(), + BomberPictureBox.getHeight() + ); + _bomberRenderer.SetPosition(random.nextInt(20, 100), random.nextInt(20, 100)); + + Draw(); + } + + private void ButtonMove_Click(ActionEvent e) + { + if (_bomberRenderer == null) + return; + + String ButtonName = ((JButton)e.getSource()).getName(); + + switch (ButtonName) + { + case "ButtonUp": + _bomberRenderer.MoveEntity(DirectionType.Up); + break; + + case "ButtonDown": + _bomberRenderer.MoveEntity(DirectionType.Down); + break; + + case "ButtonLeft": + _bomberRenderer.MoveEntity(DirectionType.Left); + break; + + case "ButtonRight": + _bomberRenderer.MoveEntity(DirectionType.Right); + break; + } + + Draw(); + } + + private void InitializeComponent() + { + BomberPictureBox = new JLabel(); + CreateButton = new JButton(); + ButtonRight = new JButton(); + ButtonDown = new JButton(); + ButtonLeft = new JButton(); + ButtonUp = new JButton(); + // + // BomberPictureBox + // + BomberPictureBox.setBounds(0, 0, 884, 461); + // + // CreateButton + // + CreateButton.setName("CreateButton"); + CreateButton.setBounds(12, 419, 80, 30); + CreateButton.setText("Создать"); + CreateButton.setBackground(new Color(225, 225, 225)); + CreateButton.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + CreateButton.setFocusable(false); + CreateButton.addActionListener(e -> ButtonCreate_Click(e)); + // + // ButtonRight + // + ButtonRight.setName("ButtonRight"); + ButtonRight.setBounds(842, 419, 30, 30); + ButtonRight.setBackground(new Color(225, 225, 225)); + ButtonRight.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + ButtonRight.setFocusable(false); + ButtonRight.setIcon(new ImageIcon("src/Resources/ArrowRight.png")); + ButtonRight.addActionListener(e -> ButtonMove_Click(e)); + // + // ButtonDown + // + ButtonDown.setName("ButtonDown"); + ButtonDown.setBounds(806, 419, 30, 30); + ButtonDown.setBackground(new Color(225, 225, 225)); + ButtonDown.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + ButtonDown.setFocusable(false); + ButtonDown.setIcon(new ImageIcon("src/Resources/ArrowDown.png")); + ButtonDown.addActionListener(e -> ButtonMove_Click(e)); + // + // ButtonLeft + // + ButtonLeft.setName("ButtonLeft"); + ButtonLeft.setBounds(770, 419, 30, 30); + ButtonLeft.setBackground(new Color(225, 225, 225)); + ButtonLeft.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + ButtonLeft.setFocusable(false); + ButtonLeft.setIcon(new ImageIcon("src/Resources/ArrowLeft.png")); + ButtonLeft.addActionListener(e -> ButtonMove_Click(e)); + // + // ButtonUp + // + ButtonUp.setName("ButtonUp"); + ButtonUp.setBounds(806, 383, 30, 30); + ButtonUp.setBackground(new Color(225, 225, 225)); + ButtonUp.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + ButtonUp.setFocusable(false); + ButtonUp.setIcon(new ImageIcon("src/Resources/ArrowUp.png")); + ButtonUp.addActionListener(e -> ButtonMove_Click(e)); + // + // BomberForm + // + setTitle("Бомбардировщик"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setSize(900, 500); + setLayout(null); + setLocationRelativeTo(null); + setVisible(true); + add(ButtonUp); + add(ButtonLeft); + add(ButtonDown); + add(ButtonRight); + add(CreateButton); + add(BomberPictureBox); + } + + private JLabel BomberPictureBox; + private JButton CreateButton; + private JButton ButtonRight; + private JButton ButtonDown; + private JButton ButtonLeft; + private JButton ButtonUp; +} diff --git a/src/BomberRenderer.java b/src/BomberRenderer.java new file mode 100644 index 0000000..4eb202f --- /dev/null +++ b/src/BomberRenderer.java @@ -0,0 +1,214 @@ +import java.awt.*; + +public class BomberRenderer +{ + public BomberEntity EntityBomber; + + private int _pictureWidth; + private int _pictureHeight; + + private int _startPosX; + private int _startPosY; + + private int _bomberWidth = 200; + private int _bomberHeight = 200; + + public boolean Init(int Speed, double Weight, Color BodyColor, Color AdditionalColor, boolean FuelTanks, boolean Bombs, int Width, int Height) + { + if (Width < _bomberWidth || Height < _bomberHeight) + return false; + + _pictureWidth = Width; + _pictureHeight = Height; + + EntityBomber = new BomberEntity(); + EntityBomber.Init(Speed, Weight, BodyColor, AdditionalColor, FuelTanks, Bombs); + + return true; + } + + public void SetPosition(int x, int y) + { + if (EntityBomber == null) + return; + + if (x < 0) + x = 0; + else if (x + _bomberWidth > _pictureWidth) + x = _pictureWidth - _bomberWidth; + + _startPosX = x; + + if (y < 0) + y = 0; + else if (y + _bomberHeight > _pictureHeight) + y = _pictureHeight - _bomberHeight; + + _startPosY = y; + } + + public void MoveEntity(DirectionType Direction) + { + if (EntityBomber == null) + return; + + switch (Direction) + { + case Up: + if (_startPosY - EntityBomber.Step > 0) + _startPosY -= (int)EntityBomber.Step; + + break; + + case Down: + if (_startPosY + _bomberHeight + EntityBomber.Step <= _pictureHeight) + _startPosY += (int)EntityBomber.Step; + + break; + + case Left: + if (_startPosX - EntityBomber.Step > 0) + _startPosX -= (int)EntityBomber.Step; + + break; + + case Right: + if (_startPosX + _bomberWidth + EntityBomber.Step <= _pictureWidth) + _startPosX += (int)EntityBomber.Step; + + break; + } + } + + public void DrawEntity(Graphics g) + { + if (EntityBomber == null) + return; + + /** Отрисовка основной части */ + g.setColor(EntityBomber.BodyColor); + + int[] LeftWingX = { + _startPosX + 90, + _startPosX + 100, + _startPosX + 108, + _startPosX + 90, + }; + int[] LeftWingY = { + _startPosY, + _startPosY, + _startPosY + 85, + _startPosY + 85, + }; + g.drawPolygon(LeftWingX, LeftWingY, 4); + + + int[] RightWingX = { + _startPosX + 90, + _startPosX + 100, + _startPosX + 108, + _startPosX + 90, + }; + int[] RightWingY = { + _startPosY + 200, + _startPosY + 200, + _startPosY + 115, + _startPosY + 115, + }; + g.drawPolygon(RightWingX, RightWingY, 4); + + int[] BodyX = { + _startPosX + 35, + _startPosX + 200, + _startPosX + 200, + _startPosX + 35, + }; + int[] BodyY = { + _startPosY + 85, + _startPosY + 85, + _startPosY + 115, + _startPosY + 115, + }; + g.drawPolygon(BodyX, BodyY, 4); + + int[] NoseX = { + _startPosX, + _startPosX + 35, + _startPosX + 35, + }; + int[] NoseY = { + _startPosY + 100, + _startPosY + 85, + _startPosY + 115, + }; + g.fillPolygon(NoseX, NoseY, 3); + + int[] BackLeftWingX = { + _startPosX + 170, + _startPosX + 200, + _startPosX + 200, + _startPosX + 170, + }; + int[] BackLeftWingY = { + _startPosY + 70, + _startPosY + 40, + _startPosY + 85, + _startPosY + 85, + }; + g.drawPolygon(BackLeftWingX, BackLeftWingY, 4); + + int[] BackRightWingX = { + _startPosX + 170, + _startPosX + 200, + _startPosX + 200, + _startPosX + 170, + }; + int[] BackRightWingY = { + _startPosY + 130, + _startPosY + 160, + _startPosY + 115, + _startPosY + 115, + }; + g.drawPolygon(BackRightWingX, BackRightWingY, 4); + + /** Отрисовка дополнительных элементов */ + g.setColor(EntityBomber.AdditionalColor); + + if (EntityBomber.FuelTanks) + { + int[] LeftGasTankX = { + _startPosX + 50, + _startPosX + 75, + _startPosX + 75, + _startPosX + 50, + }; + int[] LeftGasTankY = { + _startPosY + 85, + _startPosY + 85, + _startPosY + 70, + _startPosY + 70, + }; + g.fillPolygon(LeftGasTankX, LeftGasTankY, 4); + + int[] RightGasTankX = { + _startPosX + 50, + _startPosX + 75, + _startPosX + 75, + _startPosX + 50, + }; + int[] RightGasTankY = { + _startPosY + 115, + _startPosY + 115, + _startPosY + 130, + _startPosY + 130, + }; + g.fillPolygon(RightGasTankX, RightGasTankY, 4); + } + + if (EntityBomber.Bombs) + { + g.fillOval(_startPosX + 110, _startPosY + 115, 50, 25); + g.fillOval(_startPosX + 110, _startPosY + 60, 50, 25); + } + } +} diff --git a/src/DirectionType.java b/src/DirectionType.java new file mode 100644 index 0000000..7726557 --- /dev/null +++ b/src/DirectionType.java @@ -0,0 +1,7 @@ +public enum DirectionType +{ + Up, + Down, + Left, + Right +} diff --git a/src/Program.java b/src/Program.java new file mode 100644 index 0000000..99d7e3f --- /dev/null +++ b/src/Program.java @@ -0,0 +1,6 @@ +public class Program { + public static void main(String[] args) throws Exception + { + new BomberForm(); + } +} diff --git a/src/Resources/ArrowDown.png b/src/Resources/ArrowDown.png new file mode 100644 index 0000000000000000000000000000000000000000..1a2d552eaa622ad0094b4ce876a5c8d4344c9bea GIT binary patch literal 557 zcmV+|0@D47P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!T` zX5$3J8jP%tC_Tg)OfncX7!F1ah6DNm9?;!T?!E`ZC$y8V3y&=M*%1$ zl!T}x)0b~w{`2zi8r-^hdx4^YlKZcpzZIF7m@I(OS`bwXU%5EBRW#K#3oo3%kooi1 zkCUIje7-9tEY9@x``7uX2}_mir+mE&mt928pRC vs*-0Y5&*lrrn;u2w4}5gEJ85HGB5xDIlYBIDRxsV00000NkvXXu0mjf_7vZ& literal 0 HcmV?d00001 diff --git a/src/Resources/ArrowLeft.png b/src/Resources/ArrowLeft.png new file mode 100644 index 0000000000000000000000000000000000000000..c982fa63e6a5079d5fd5072c1e12965129bb2ca7 GIT binary patch literal 507 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!TVK~zXfV;BVl zfrO|e6O>6Eux;x$Mj!>k)B|hQtbrRUDK67-@1GA@Bjb*Il@CDTK4bTU#zUGyy?X0DToS-AC#4n`!6Xb^f%E&#i@vb@TD;ev(pfi9K=a{n;` z0gzq?q>g}m0c8INsUrgX17a>9UcgvWT~o4f!J?KwzyGi^GBN%I8o>-!LK*O2`uX!G zGa~~dE0{~HyNCerpjfmsH?440P({@!pYBhAh2=cMsS#efRu!kyOg*TI7Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!TDCV`TzevSgf?L6mB@9l(;lVkZ9W^BqbQmT{sKU^T)~2Y5To9_dNoF{3do!=xSzV zWPfXGVaIg%#G!u>)noz@A<-r=A@Tpf;Q0>>nyu=J>iSSAMv#jYfs8yL{ss~Ni4p-A zf#5eV2+Wz7n4Ew9{K@?N`ws?DQQ=#8g?VL#g@qeI2HOJ_9)PGP4*)Is547O__ix{s z#3dzuM8`!oQWld~!T+D^Z0vt24hkR*4vHT?elUoLh}_CAf&>Lr9eF^AU${|BSmM8; zywZOe8QCq$@~SA2M^bW=lapgOar!tT(6#?O+&y<(yK>z%FxbCm;-rb4K-a&qw{l`S zcx)f($*rZO1?-6V^XKchIJum1ck{>rO8`MZZV~x$CM6*Sjt3xZE+#By3l;=|=;#>g sCxl6pCKDU!!~silOX?ap903CZ0E;VmMfgtsasU7T07*qoM6N<$f+3R5uK)l5 literal 0 HcmV?d00001 diff --git a/src/Resources/ArrowUp.png b/src/Resources/ArrowUp.png new file mode 100644 index 0000000000000000000000000000000000000000..45ca860fa4f7b9da130c66ed6b6a55b265fd7d28 GIT binary patch literal 539 zcmV+$0_6RPP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!Tni8-GRE%t(qNvIYqASa*+~uU@|H?|s{Q$8+Vrt6jU^$XOQ9%({qm-nK zf{di>Gf6S2{~#p#(tRMnt zU Date: Mon, 27 Nov 2023 20:18:42 +0400 Subject: [PATCH 2/6] Implement engines renderer --- src/BomberEntity.java | 24 ++++++++++++++++++------ src/BomberRenderer.java | 22 +++++++++++++++++----- src/EngineRenderer.java | 38 ++++++++++++++++++++++++++++++++++++++ src/EnginesAmount.java | 6 ++++++ 4 files changed, 79 insertions(+), 11 deletions(-) create mode 100644 src/EngineRenderer.java create mode 100644 src/EnginesAmount.java diff --git a/src/BomberEntity.java b/src/BomberEntity.java index 5511fcb..8b7ece0 100644 --- a/src/BomberEntity.java +++ b/src/BomberEntity.java @@ -2,12 +2,12 @@ import java.awt.Color; public class BomberEntity { - public int Speed; - public double Weight; - public Color BodyColor; - public Color AdditionalColor; - public boolean Bombs; - public boolean FuelTanks; + private int Speed; + private double Weight; + private Color BodyColor; + private Color AdditionalColor; + private boolean Bombs; + private boolean FuelTanks; public double Step; public void Init(int Speed, double Weight, Color BodyColor, Color AdditionalColor, boolean FuelTanks, boolean Bombs) @@ -21,4 +21,16 @@ public class BomberEntity this.Step = (double)Speed * 100 / Weight * 5 / 2; } + + public int GetSpeed() { return Speed; } + + public double GetWeight() { return Weight; } + + public Color GetBodyColor() { return BodyColor; } + + public Color GetAdditionalColor() { return AdditionalColor; } + + public boolean GetBombs() { return Bombs; } + + public boolean GetFuelTanks() { return FuelTanks; } } diff --git a/src/BomberRenderer.java b/src/BomberRenderer.java index 4eb202f..8a7ee8f 100644 --- a/src/BomberRenderer.java +++ b/src/BomberRenderer.java @@ -1,8 +1,9 @@ import java.awt.*; +import java.util.Random; public class BomberRenderer { - public BomberEntity EntityBomber; + private BomberEntity EntityBomber; private int _pictureWidth; private int _pictureHeight; @@ -13,6 +14,8 @@ public class BomberRenderer private int _bomberWidth = 200; private int _bomberHeight = 200; + public EngineRenderer EngineRenderer; + public boolean Init(int Speed, double Weight, Color BodyColor, Color AdditionalColor, boolean FuelTanks, boolean Bombs, int Width, int Height) { if (Width < _bomberWidth || Height < _bomberHeight) @@ -23,10 +26,17 @@ public class BomberRenderer EntityBomber = new BomberEntity(); EntityBomber.Init(Speed, Weight, BodyColor, AdditionalColor, FuelTanks, Bombs); + + EngineRenderer = new EngineRenderer(); + + Random Random = new Random(); + EngineRenderer.SetAmount(Random.nextInt(1, 7)); return true; } + public BomberEntity GetEntityBomber() { return EntityBomber; } + public void SetPosition(int x, int y) { if (EntityBomber == null) @@ -86,7 +96,7 @@ public class BomberRenderer return; /** Отрисовка основной части */ - g.setColor(EntityBomber.BodyColor); + g.setColor(EntityBomber.GetBodyColor()); int[] LeftWingX = { _startPosX + 90, @@ -172,9 +182,9 @@ public class BomberRenderer g.drawPolygon(BackRightWingX, BackRightWingY, 4); /** Отрисовка дополнительных элементов */ - g.setColor(EntityBomber.AdditionalColor); + g.setColor(EntityBomber.GetAdditionalColor()); - if (EntityBomber.FuelTanks) + if (EntityBomber.GetFuelTanks()) { int[] LeftGasTankX = { _startPosX + 50, @@ -205,10 +215,12 @@ public class BomberRenderer g.fillPolygon(RightGasTankX, RightGasTankY, 4); } - if (EntityBomber.Bombs) + if (EntityBomber.GetBombs()) { g.fillOval(_startPosX + 110, _startPosY + 115, 50, 25); g.fillOval(_startPosX + 110, _startPosY + 60, 50, 25); } + + EngineRenderer.DrawEngines(g, EntityBomber.GetBodyColor(), _startPosX, _startPosY); } } diff --git a/src/EngineRenderer.java b/src/EngineRenderer.java new file mode 100644 index 0000000..fd6c05c --- /dev/null +++ b/src/EngineRenderer.java @@ -0,0 +1,38 @@ +import java.awt.*; + +public class EngineRenderer +{ + private EnginesAmount Amount; + + public void SetAmount(int Amount) + { + if (Amount <= 2) + this.Amount = EnginesAmount.Two; + + else if (Amount > 2 && Amount <= 4) + this.Amount = EnginesAmount.Four; + + else + this.Amount = EnginesAmount.Six; + } + + public void DrawEngines(Graphics g, Color BodyColor, int _startPosX, int _startPosY) + { + g.setColor(BodyColor); + + g.fillOval(_startPosX + 83, _startPosY + 50, 30, 15); + g.fillOval(_startPosX + 83, _startPosY + 135, 30, 15); + + if (Amount == EnginesAmount.Two) + return; + + g.fillOval(_startPosX + 83, _startPosY + 30, 30, 15); + g.fillOval(_startPosX + 83, _startPosY + 155, 30, 15); + + if (Amount == EnginesAmount.Four) + return; + + g.fillOval(_startPosX + 83, _startPosY + 10, 30, 15); + g.fillOval(_startPosX + 83, _startPosY + 175, 30, 15); + } +} diff --git a/src/EnginesAmount.java b/src/EnginesAmount.java new file mode 100644 index 0000000..b142799 --- /dev/null +++ b/src/EnginesAmount.java @@ -0,0 +1,6 @@ +public enum EnginesAmount +{ + Two, + Four, + Six +} -- 2.25.1 From d66d17619bb9056897c79df7ad9a9ca323ef8554 Mon Sep 17 00:00:00 2001 From: olshab Date: Mon, 27 Nov 2023 22:53:25 +0400 Subject: [PATCH 3/6] Move to AirBomber package --- src/{ => AirBomber}/BomberEntity.java | 2 ++ src/{ => AirBomber}/BomberForm.java | 2 ++ src/{ => AirBomber}/BomberRenderer.java | 2 ++ src/{ => AirBomber}/DirectionType.java | 2 ++ src/{ => AirBomber}/EngineRenderer.java | 2 ++ src/{ => AirBomber}/EnginesAmount.java | 2 ++ src/{ => AirBomber}/Program.java | 2 ++ src/{ => AirBomber}/Resources/ArrowDown.png | Bin src/{ => AirBomber}/Resources/ArrowLeft.png | Bin src/{ => AirBomber}/Resources/ArrowRight.png | Bin src/{ => AirBomber}/Resources/ArrowUp.png | Bin 11 files changed, 14 insertions(+) rename src/{ => AirBomber}/BomberEntity.java (97%) rename src/{ => AirBomber}/BomberForm.java (99%) rename src/{ => AirBomber}/BomberRenderer.java (99%) rename src/{ => AirBomber}/DirectionType.java (77%) rename src/{ => AirBomber}/EngineRenderer.java (98%) rename src/{ => AirBomber}/EnginesAmount.java (75%) rename src/{ => AirBomber}/Program.java (86%) rename src/{ => AirBomber}/Resources/ArrowDown.png (100%) rename src/{ => AirBomber}/Resources/ArrowLeft.png (100%) rename src/{ => AirBomber}/Resources/ArrowRight.png (100%) rename src/{ => AirBomber}/Resources/ArrowUp.png (100%) diff --git a/src/BomberEntity.java b/src/AirBomber/BomberEntity.java similarity index 97% rename from src/BomberEntity.java rename to src/AirBomber/BomberEntity.java index 8b7ece0..4c1fbcb 100644 --- a/src/BomberEntity.java +++ b/src/AirBomber/BomberEntity.java @@ -1,3 +1,5 @@ +package AirBomber; + import java.awt.Color; public class BomberEntity diff --git a/src/BomberForm.java b/src/AirBomber/BomberForm.java similarity index 99% rename from src/BomberForm.java rename to src/AirBomber/BomberForm.java index 8bd7cd9..0ceee76 100644 --- a/src/BomberForm.java +++ b/src/AirBomber/BomberForm.java @@ -1,3 +1,5 @@ +package AirBomber; + import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; diff --git a/src/BomberRenderer.java b/src/AirBomber/BomberRenderer.java similarity index 99% rename from src/BomberRenderer.java rename to src/AirBomber/BomberRenderer.java index 8a7ee8f..95bfa4b 100644 --- a/src/BomberRenderer.java +++ b/src/AirBomber/BomberRenderer.java @@ -1,3 +1,5 @@ +package AirBomber; + import java.awt.*; import java.util.Random; diff --git a/src/DirectionType.java b/src/AirBomber/DirectionType.java similarity index 77% rename from src/DirectionType.java rename to src/AirBomber/DirectionType.java index 7726557..f4391c0 100644 --- a/src/DirectionType.java +++ b/src/AirBomber/DirectionType.java @@ -1,3 +1,5 @@ +package AirBomber; + public enum DirectionType { Up, diff --git a/src/EngineRenderer.java b/src/AirBomber/EngineRenderer.java similarity index 98% rename from src/EngineRenderer.java rename to src/AirBomber/EngineRenderer.java index fd6c05c..16166d7 100644 --- a/src/EngineRenderer.java +++ b/src/AirBomber/EngineRenderer.java @@ -1,3 +1,5 @@ +package AirBomber; + import java.awt.*; public class EngineRenderer diff --git a/src/EnginesAmount.java b/src/AirBomber/EnginesAmount.java similarity index 75% rename from src/EnginesAmount.java rename to src/AirBomber/EnginesAmount.java index b142799..2e977b2 100644 --- a/src/EnginesAmount.java +++ b/src/AirBomber/EnginesAmount.java @@ -1,3 +1,5 @@ +package AirBomber; + public enum EnginesAmount { Two, diff --git a/src/Program.java b/src/AirBomber/Program.java similarity index 86% rename from src/Program.java rename to src/AirBomber/Program.java index 99d7e3f..9f3a993 100644 --- a/src/Program.java +++ b/src/AirBomber/Program.java @@ -1,3 +1,5 @@ +package AirBomber; + public class Program { public static void main(String[] args) throws Exception { diff --git a/src/Resources/ArrowDown.png b/src/AirBomber/Resources/ArrowDown.png similarity index 100% rename from src/Resources/ArrowDown.png rename to src/AirBomber/Resources/ArrowDown.png diff --git a/src/Resources/ArrowLeft.png b/src/AirBomber/Resources/ArrowLeft.png similarity index 100% rename from src/Resources/ArrowLeft.png rename to src/AirBomber/Resources/ArrowLeft.png diff --git a/src/Resources/ArrowRight.png b/src/AirBomber/Resources/ArrowRight.png similarity index 100% rename from src/Resources/ArrowRight.png rename to src/AirBomber/Resources/ArrowRight.png diff --git a/src/Resources/ArrowUp.png b/src/AirBomber/Resources/ArrowUp.png similarity index 100% rename from src/Resources/ArrowUp.png rename to src/AirBomber/Resources/ArrowUp.png -- 2.25.1 From c24b588223ae10312f9741743c8621236ce63e71 Mon Sep 17 00:00:00 2001 From: olshab Date: Mon, 27 Nov 2023 22:51:11 +0400 Subject: [PATCH 4/6] temp --- src/AirBomber/BomberForm.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/AirBomber/BomberForm.java b/src/AirBomber/BomberForm.java index 0ceee76..0c5c277 100644 --- a/src/AirBomber/BomberForm.java +++ b/src/AirBomber/BomberForm.java @@ -1,6 +1,7 @@ package AirBomber; import javax.swing.*; + import java.awt.*; import java.awt.event.ActionEvent; import java.awt.image.BufferedImage; -- 2.25.1 From f16efd49cd42ace3c44044d10b624905607f4995 Mon Sep 17 00:00:00 2001 From: olshab Date: Tue, 28 Nov 2023 21:24:07 +0400 Subject: [PATCH 5/6] Fix icons --- src/AirBomber/BomberForm.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AirBomber/BomberForm.java b/src/AirBomber/BomberForm.java index 0c5c277..4121002 100644 --- a/src/AirBomber/BomberForm.java +++ b/src/AirBomber/BomberForm.java @@ -108,7 +108,7 @@ public class BomberForm extends JFrame ButtonRight.setBackground(new Color(225, 225, 225)); ButtonRight.setFont(new Font("Segoe UI", Font.PLAIN, 11)); ButtonRight.setFocusable(false); - ButtonRight.setIcon(new ImageIcon("src/Resources/ArrowRight.png")); + ButtonRight.setIcon(new ImageIcon("src/AirBomber/Resources/ArrowRight.png")); ButtonRight.addActionListener(e -> ButtonMove_Click(e)); // // ButtonDown @@ -118,7 +118,7 @@ public class BomberForm extends JFrame ButtonDown.setBackground(new Color(225, 225, 225)); ButtonDown.setFont(new Font("Segoe UI", Font.PLAIN, 11)); ButtonDown.setFocusable(false); - ButtonDown.setIcon(new ImageIcon("src/Resources/ArrowDown.png")); + ButtonDown.setIcon(new ImageIcon("src/AirBomber/Resources/ArrowDown.png")); ButtonDown.addActionListener(e -> ButtonMove_Click(e)); // // ButtonLeft @@ -128,7 +128,7 @@ public class BomberForm extends JFrame ButtonLeft.setBackground(new Color(225, 225, 225)); ButtonLeft.setFont(new Font("Segoe UI", Font.PLAIN, 11)); ButtonLeft.setFocusable(false); - ButtonLeft.setIcon(new ImageIcon("src/Resources/ArrowLeft.png")); + ButtonLeft.setIcon(new ImageIcon("src/AirBomber/Resources/ArrowLeft.png")); ButtonLeft.addActionListener(e -> ButtonMove_Click(e)); // // ButtonUp @@ -138,7 +138,7 @@ public class BomberForm extends JFrame ButtonUp.setBackground(new Color(225, 225, 225)); ButtonUp.setFont(new Font("Segoe UI", Font.PLAIN, 11)); ButtonUp.setFocusable(false); - ButtonUp.setIcon(new ImageIcon("src/Resources/ArrowUp.png")); + ButtonUp.setIcon(new ImageIcon("src/AirBomber/Resources/ArrowUp.png")); ButtonUp.addActionListener(e -> ButtonMove_Click(e)); // // BomberForm -- 2.25.1 From e89ec6c1d74ed3d1246b58cef4f1c6f6574f7f91 Mon Sep 17 00:00:00 2001 From: olshab Date: Tue, 28 Nov 2023 22:47:00 +0400 Subject: [PATCH 6/6] Fix --- src/AirBomber/BomberForm.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/AirBomber/BomberForm.java b/src/AirBomber/BomberForm.java index 4121002..e5a95f4 100644 --- a/src/AirBomber/BomberForm.java +++ b/src/AirBomber/BomberForm.java @@ -18,6 +18,9 @@ public class BomberForm extends JFrame private void Draw() { + if (_bomberRenderer == null) + return; + BufferedImage bmp = new BufferedImage( BomberPictureBox.getWidth(), BomberPictureBox.getHeight(), -- 2.25.1