diff --git a/.gitignore b/.gitignore
index 57940fd..8e61364 100644
--- a/.gitignore
+++ b/.gitignore
@@ -76,4 +76,5 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
+.idea
diff --git a/ProjectBomber/ProjectBomber.iml b/ProjectBomber/ProjectBomber.iml
new file mode 100644
index 0000000..5cf7938
--- /dev/null
+++ b/ProjectBomber/ProjectBomber.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ProjectBomber/src/ProjectBomber/DrawingBomber.java b/ProjectBomber/src/ProjectBomber/DrawingBomber.java
new file mode 100644
index 0000000..f0eb819
--- /dev/null
+++ b/ProjectBomber/src/ProjectBomber/DrawingBomber.java
@@ -0,0 +1,220 @@
+package ProjectBomber;
+
+import java.awt.*;
+
+public class DrawingBomber {
+ public EntityBomber EntityBomber;
+ private DrawingEngines _drawingEngines;
+ private int _pictureWidth;
+ private int _pictureHeight;
+ private int _startPosX;
+ private int _startPosY;
+ private final int _bomberWidth = 110;
+ private final int _bomberHeight = 110;
+
+ 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;
+ _drawingEngines = new DrawingEngines();
+ EntityBomber = new EntityBomber();
+ EntityBomber.Init(speed, weight, bodyColor, additionalColor, fuelTanks, bombs);
+ return true;
+ }
+
+ public void SetEnginesCount(int enginesCount) {
+ _drawingEngines.SetEnumEnginesCount(enginesCount);
+ }
+
+ public void SetPosition(int x, int y) {
+ if (x < 0) {
+ x = 0;
+ } else if (x > _pictureWidth - _bomberWidth) {
+ x = _pictureWidth - _bomberWidth;
+ }
+ _startPosX = x;
+
+ if (y < 0) {
+ y = 0;
+ } else if (y > _pictureHeight - _bomberHeight) {
+ y = _pictureHeight - _bomberHeight;
+ }
+ _startPosY = y;
+ }
+
+ public void MoveTransport(EnumDirectionType direction) {
+ if (EntityBomber == null) {
+ return;
+ }
+ switch (direction) {
+ case Up -> {
+ if (_startPosY - EntityBomber.Step() >= 0) {
+ _startPosY -= (int) EntityBomber.Step();
+ }
+ }
+ case Down -> {
+ if (_startPosY + _bomberHeight + EntityBomber.Step() <= _pictureHeight) {
+ _startPosY += (int) EntityBomber.Step();
+ }
+ }
+ case Left -> {
+ if (_startPosX - EntityBomber.Step() >= 0) {
+ _startPosX -= (int) EntityBomber.Step();
+ }
+ }
+ case Right -> {
+ if (_startPosX + _bomberWidth + EntityBomber.Step() <= _pictureWidth) {
+ _startPosX += (int) EntityBomber.Step();
+ }
+ }
+ }
+ }
+
+ public void DrawTransport(Graphics g) {
+ if (EntityBomber == null) {
+ return;
+ }
+ Graphics2D g2d = (Graphics2D) g;
+
+ Color bodyColor = EntityBomber.BodyColor;
+ Color additionalColor = EntityBomber.AdditionalColor;
+ Color blackColor = Color.BLACK;
+
+ _drawingEngines.DrawEngines(g, additionalColor, _startPosX, _startPosY, _bomberWidth, _bomberHeight);
+
+ // Длина фюзеляжа
+ int bodyHeight = _bomberHeight / 8;
+ int bodyWidth = _bomberWidth - _bomberWidth / 7;
+
+ // Рисуем бомбы
+ if (EntityBomber.Bombs) {
+ Polygon bombTailPolygon = new Polygon();
+ bombTailPolygon.addPoint(_startPosX + _bomberWidth / 2 - _bomberWidth / 8 + bodyHeight * 3 - 5,
+ _startPosY + _bomberHeight / 2 - bodyHeight / 2 - _bomberHeight / 3 + bodyHeight / 2);
+ bombTailPolygon.addPoint(_startPosX + _bomberWidth / 2 - _bomberWidth / 8 + bodyHeight * 3 + 5,
+ _startPosY + _bomberHeight / 2 - bodyHeight / 2 - _bomberHeight / 3 + bodyHeight / 2 - 5);
+ bombTailPolygon.addPoint(_startPosX + _bomberWidth / 2 - _bomberWidth / 8 + bodyHeight * 3 + 5,
+ _startPosY + _bomberHeight / 2 - bodyHeight / 2 - _bomberHeight / 3 + bodyHeight / 2 + 5);
+ bombTailPolygon.addPoint(_startPosX + _bomberWidth / 2 - _bomberWidth / 8 + bodyHeight * 3 - 5,
+ _startPosY + _bomberHeight / 2 - bodyHeight / 2 - _bomberHeight / 3 + bodyHeight / 2);
+
+ g2d.setColor(additionalColor);
+ g2d.fillPolygon(bombTailPolygon);
+ g2d.setColor(blackColor);
+ g2d.drawPolygon(bombTailPolygon);
+
+ bombTailPolygon.translate(0, (int) (_bomberHeight - 2 * (_bomberHeight / 2 - bodyHeight / 2 - _bomberHeight / 3 + bodyHeight / 2 - 5) - bombTailPolygon.getBounds2D().getHeight()));
+
+ g2d.setColor(additionalColor);
+ g2d.fillPolygon(bombTailPolygon);
+ g2d.setColor(blackColor);
+ g2d.drawPolygon(bombTailPolygon);
+
+ g2d.setColor(additionalColor);
+ g2d.fillOval(
+ _startPosX + _bomberWidth / 2 - _bomberWidth / 8,
+ _startPosY + _bomberHeight / 2 - bodyHeight / 2 - _bomberHeight / 3,
+ bodyHeight * 3,
+ bodyHeight);
+
+ g2d.fillOval(
+ _startPosX + _bomberWidth / 2 - _bomberWidth / 8,
+ _startPosY + _bomberHeight / 2 - bodyHeight / 2 + _bomberHeight / 3,
+ bodyHeight * 3,
+ bodyHeight);
+
+ g2d.setColor(blackColor);
+ g2d.drawOval(
+ _startPosX + _bomberWidth / 2 - _bomberWidth / 8,
+ _startPosY + _bomberHeight / 2 - bodyHeight / 2 - _bomberHeight / 3,
+ bodyHeight * 3,
+ bodyHeight);
+ g2d.drawOval(
+ _startPosX + _bomberWidth / 2 - _bomberWidth / 8,
+ _startPosY + _bomberHeight / 2 - bodyHeight / 2 + _bomberHeight / 3,
+ bodyHeight * 3,
+ bodyHeight);
+ }
+
+ // Рисуем топливные баки
+ if (EntityBomber.FuelTanks) {
+ int fuelTanksWidth = bodyHeight * 2;
+ int fuelTanksHeight = bodyHeight / 2;
+ g2d.setColor(additionalColor);
+ g2d.fillRect(
+ _startPosX + _bomberWidth / 2 - _bomberWidth / 7,
+ _startPosY + _bomberHeight / 2 - bodyHeight - bodyHeight / 2,
+ fuelTanksWidth,
+ fuelTanksHeight);
+ g2d.fillRect(
+ _startPosX + _bomberWidth / 2 - _bomberWidth / 7,
+ _startPosY + _bomberHeight / 2 + bodyHeight / 2 + bodyHeight / 2,
+ fuelTanksWidth,
+ fuelTanksHeight);
+ g2d.setColor(blackColor);
+ g2d.drawRect(
+ _startPosX + _bomberWidth / 2 - _bomberWidth / 7,
+ _startPosY + _bomberHeight / 2 - bodyHeight - bodyHeight / 2,
+ fuelTanksWidth,
+ fuelTanksHeight);
+ g2d.drawRect(
+ _startPosX + _bomberWidth / 2 - _bomberWidth / 7,
+ _startPosY + _bomberHeight / 2 + bodyHeight / 2 + bodyHeight / 2,
+ fuelTanksWidth,
+ fuelTanksHeight);
+ }
+ // Рисуем нос
+ Polygon cockPitPolygon = new Polygon();
+ cockPitPolygon.addPoint(_startPosX, _startPosY + _bomberHeight / 2);
+ cockPitPolygon.addPoint(_startPosX + _bomberWidth / 8, _startPosY + _bomberHeight / 2 - bodyHeight / 2);
+ cockPitPolygon.addPoint(_startPosX + _bomberWidth / 8, _startPosY + _bomberHeight / 2 + bodyHeight / 2);
+
+ g2d.setColor(blackColor);
+ g2d.fillPolygon(cockPitPolygon);
+
+ // Рисуем крылья
+ Polygon wingsPolygon = new Polygon();
+ wingsPolygon.addPoint(_startPosX + _bomberWidth / 2, _startPosY);
+ wingsPolygon.addPoint(_startPosX + _bomberWidth / 2 + _bomberWidth / 15, _startPosY);
+ wingsPolygon.addPoint(_startPosX + _bomberWidth / 2 + _bomberWidth / 6, _startPosY + _bomberHeight / 2);
+ wingsPolygon.addPoint(_startPosX + _bomberWidth / 2 + _bomberWidth / 15, _startPosY + _bomberHeight);
+ wingsPolygon.addPoint(_startPosX + _bomberWidth / 2, _startPosY + _bomberHeight);
+
+ g2d.setColor(bodyColor);
+ g.fillPolygon(wingsPolygon);
+ g2d.setColor(blackColor);
+ g.drawPolygon(wingsPolygon);
+
+ // Рисуем хвостовое оперение
+ Polygon tailPolygon = new Polygon();
+ tailPolygon.addPoint(_startPosX + _bomberWidth, _startPosY + _bomberHeight / 2 - _bomberHeight / 3);
+ tailPolygon.addPoint(_startPosX + bodyWidth, _startPosY + _bomberHeight / 2 - _bomberHeight / 8);
+ tailPolygon.addPoint(_startPosX + bodyWidth, _startPosY + _bomberHeight / 2 + _bomberHeight / 8);
+ tailPolygon.addPoint(_startPosX + _bomberWidth, _startPosY + _bomberHeight / 2 + _bomberHeight / 3);
+
+ g2d.setColor(bodyColor);
+ g.fillPolygon(tailPolygon);
+ g2d.setColor(blackColor);
+ g.drawPolygon(tailPolygon);
+
+ // Рисуем фюзеляж
+ g2d.setColor(bodyColor);
+ g2d.fillRect(
+ _startPosX + _bomberWidth / 8,
+ _startPosY + _bomberHeight / 2 - bodyHeight / 2,
+ bodyWidth,
+ bodyHeight
+ );
+ g2d.setColor(blackColor);
+ g2d.drawRect(
+ _startPosX + _bomberWidth / 8,
+ _startPosY + _bomberHeight / 2 - bodyHeight / 2,
+ bodyWidth,
+ bodyHeight
+ );
+ }
+}
diff --git a/ProjectBomber/src/ProjectBomber/DrawingEngines.java b/ProjectBomber/src/ProjectBomber/DrawingEngines.java
new file mode 100644
index 0000000..db7abc2
--- /dev/null
+++ b/ProjectBomber/src/ProjectBomber/DrawingEngines.java
@@ -0,0 +1,85 @@
+package ProjectBomber;
+
+import java.awt.*;
+
+public class DrawingEngines {
+ private EnumEnginesCount _enumEnginesCount;
+
+ public void SetEnumEnginesCount(int enginesCount) {
+ for (EnumEnginesCount val : EnumEnginesCount.values()) {
+ if (val.count == enginesCount) {
+ this._enumEnginesCount = val;
+ return;
+ }
+ }
+ this._enumEnginesCount = EnumEnginesCount.Two;
+ }
+
+ private void DrawEngine(Graphics2D g2d, Color color, int x, int y, int w, int h) {
+ g2d.setColor(Color.WHITE);
+ g2d.fillRect(x, y, w, h);
+ g2d.setColor(Color.BLACK);
+ g2d.drawRect(x, y, w, h);
+ g2d.setColor(color);
+ g2d.fillRect(x, y, 6, h);
+ }
+
+ public void DrawEngines(Graphics g, Color color, int startPosX, int startPosY, int drawingWidth, int drawingHeight) {
+ if (_enumEnginesCount == null) {
+ return;
+ }
+ Graphics2D g2d = (Graphics2D) g;
+
+ int engineWidth = 20;
+ int engineHeight = 6;
+
+ if (_enumEnginesCount.count >= EnumEnginesCount.Two.count) {
+ DrawEngine(
+ g2d, color,
+ startPosX + drawingWidth - drawingWidth / 5,
+ startPosY + drawingHeight / 2 - drawingHeight / 6,
+ engineWidth,
+ engineHeight
+ );
+ DrawEngine(
+ g2d, color,
+ startPosX + drawingWidth - drawingWidth / 5,
+ startPosY + drawingHeight / 2 + drawingHeight / 6 - engineHeight,
+ engineWidth,
+ engineHeight
+ );
+ }
+ if (_enumEnginesCount.count >= EnumEnginesCount.Four.count) {
+ DrawEngine(
+ g2d, color,
+ startPosX + drawingWidth - drawingWidth / 5 + 5,
+ startPosY + drawingHeight / 2 - drawingHeight / 6 - 10,
+ engineWidth - 5,
+ engineHeight
+ );
+ DrawEngine(
+ g2d, color,
+ startPosX + drawingWidth - drawingWidth / 5 + 5,
+ startPosY + drawingHeight / 2 + drawingHeight / 6 - engineHeight + 10,
+ engineWidth - 5,
+ engineHeight
+ );
+ }
+ if (_enumEnginesCount.count >= EnumEnginesCount.Six.count) {
+ DrawEngine(
+ g2d, color,
+ startPosX + drawingWidth / 2 - 10,
+ startPosY + drawingHeight / 2 - drawingHeight / 6 - 10,
+ engineWidth,
+ engineHeight
+ );
+ DrawEngine(
+ g2d, color,
+ startPosX + drawingWidth / 2 - 10,
+ startPosY + drawingHeight / 2 + drawingHeight / 6 + 3,
+ engineWidth,
+ engineHeight
+ );
+ }
+ }
+}
diff --git a/ProjectBomber/src/ProjectBomber/EntityBomber.java b/ProjectBomber/src/ProjectBomber/EntityBomber.java
new file mode 100644
index 0000000..fb9b6df
--- /dev/null
+++ b/ProjectBomber/src/ProjectBomber/EntityBomber.java
@@ -0,0 +1,25 @@
+package ProjectBomber;
+
+import java.awt.*;
+
+public class EntityBomber {
+ public int Speed;
+ public double Weight;
+ public Color BodyColor;
+ public Color AdditionalColor;
+ public boolean FuelTanks;
+ public boolean Bombs;
+
+ public double Step() {
+ return (double) Speed * 250 / Weight;
+ }
+
+ public void Init(int speed, double weight, Color bodyColor, Color additionalColor, boolean fuelTanks, boolean bombs) {
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+ AdditionalColor = additionalColor;
+ FuelTanks = fuelTanks;
+ Bombs = bombs;
+ }
+}
diff --git a/ProjectBomber/src/ProjectBomber/EnumDirectionType.java b/ProjectBomber/src/ProjectBomber/EnumDirectionType.java
new file mode 100644
index 0000000..b09cd79
--- /dev/null
+++ b/ProjectBomber/src/ProjectBomber/EnumDirectionType.java
@@ -0,0 +1,5 @@
+package ProjectBomber;
+
+public enum EnumDirectionType {
+ Up, Down, Left, Right
+}
diff --git a/ProjectBomber/src/ProjectBomber/EnumEnginesCount.java b/ProjectBomber/src/ProjectBomber/EnumEnginesCount.java
new file mode 100644
index 0000000..99a1184
--- /dev/null
+++ b/ProjectBomber/src/ProjectBomber/EnumEnginesCount.java
@@ -0,0 +1,11 @@
+package ProjectBomber;
+
+public enum EnumEnginesCount {
+ Two(2),
+ Four(4),
+ Six(6);
+ public final int count;
+ EnumEnginesCount(int count) {
+ this.count = count;
+ }
+}
diff --git a/ProjectBomber/src/ProjectBomber/FormBomber.form b/ProjectBomber/src/ProjectBomber/FormBomber.form
new file mode 100644
index 0000000..569d8c7
--- /dev/null
+++ b/ProjectBomber/src/ProjectBomber/FormBomber.form
@@ -0,0 +1,94 @@
+
+
diff --git a/ProjectBomber/src/ProjectBomber/FormBomber.java b/ProjectBomber/src/ProjectBomber/FormBomber.java
new file mode 100644
index 0000000..839af30
--- /dev/null
+++ b/ProjectBomber/src/ProjectBomber/FormBomber.java
@@ -0,0 +1,84 @@
+package ProjectBomber;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionListener;
+import java.util.Random;
+
+public class FormBomber {
+ DrawingBomber _drawingBomber = new DrawingBomber();
+ private JButton buttonCreate;
+ private JPanel pictureBox;
+ private JButton buttonDown;
+ private JButton buttonUp;
+ private JButton buttonLeft;
+ private JButton buttonRight;
+
+ public JPanel getPictureBox() {
+ return pictureBox;
+ }
+
+ public FormBomber() {
+ buttonUp.setName("buttonUp");
+ buttonDown.setName("buttonDown");
+ buttonLeft.setName("buttonLeft");
+ buttonRight.setName("buttonRight");
+
+ buttonCreate.addActionListener(e -> {
+ _drawingBomber = new DrawingBomber();
+ Random random = new Random();
+
+ _drawingBomber.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()
+ );
+
+ _drawingBomber.SetEnginesCount(random.nextInt(2, 7));
+ _drawingBomber.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100));
+
+ Draw();
+ });
+
+ ActionListener buttonMoveClickedListener = e -> {
+ String buttonName = ((JButton) e.getSource()).getName();
+
+ switch (buttonName) {
+ case ("buttonUp") -> {
+ _drawingBomber.MoveTransport(EnumDirectionType.Up);
+ }
+ case ("buttonDown") -> {
+ _drawingBomber.MoveTransport(EnumDirectionType.Down);
+ }
+ case ("buttonLeft") -> {
+ _drawingBomber.MoveTransport(EnumDirectionType.Left);
+ }
+ case ("buttonRight") -> {
+ _drawingBomber.MoveTransport(EnumDirectionType.Right);
+ }
+ }
+
+ Draw();
+ };
+
+ buttonUp.addActionListener(buttonMoveClickedListener);
+ buttonDown.addActionListener(buttonMoveClickedListener);
+ buttonLeft.addActionListener(buttonMoveClickedListener);
+ buttonRight.addActionListener(buttonMoveClickedListener);
+ }
+
+ public void Draw() {
+ if (_drawingBomber.EntityBomber == null) {
+ return;
+ }
+
+ Graphics g = pictureBox.getGraphics();
+ pictureBox.paint(g);
+ _drawingBomber.DrawTransport(g);
+ }
+}
diff --git a/ProjectBomber/src/ProjectBomber/Main.java b/ProjectBomber/src/ProjectBomber/Main.java
new file mode 100644
index 0000000..b77ef84
--- /dev/null
+++ b/ProjectBomber/src/ProjectBomber/Main.java
@@ -0,0 +1,5 @@
+package ProjectBomber;
+
+public class Main {
+ public static void main(String[] args) {MainFrameBomber mainFrameBomber = new MainFrameBomber();}
+}
\ No newline at end of file
diff --git a/ProjectBomber/src/ProjectBomber/MainFrameBomber.java b/ProjectBomber/src/ProjectBomber/MainFrameBomber.java
new file mode 100644
index 0000000..afe554b
--- /dev/null
+++ b/ProjectBomber/src/ProjectBomber/MainFrameBomber.java
@@ -0,0 +1,19 @@
+package ProjectBomber;
+
+import javax.swing.*;
+
+public class MainFrameBomber extends JFrame {
+ private FormBomber _formBomber;
+
+ public MainFrameBomber() {
+ super();
+ setTitle("Бомбардировщик");
+ setDefaultCloseOperation(EXIT_ON_CLOSE);
+ _formBomber = new FormBomber();
+ setContentPane(_formBomber.getPictureBox());
+ setDefaultLookAndFeelDecorated(false);
+ setLocation(300, 100);
+ pack();
+ setVisible(true);
+ }
+}
diff --git a/ProjectBomber/src/ProjectBomber/img/arrowDOWN.png b/ProjectBomber/src/ProjectBomber/img/arrowDOWN.png
new file mode 100644
index 0000000..7ef7c08
Binary files /dev/null and b/ProjectBomber/src/ProjectBomber/img/arrowDOWN.png differ
diff --git a/ProjectBomber/src/ProjectBomber/img/arrowLEFT.png b/ProjectBomber/src/ProjectBomber/img/arrowLEFT.png
new file mode 100644
index 0000000..92ca017
Binary files /dev/null and b/ProjectBomber/src/ProjectBomber/img/arrowLEFT.png differ
diff --git a/ProjectBomber/src/ProjectBomber/img/arrowRIGHT.png b/ProjectBomber/src/ProjectBomber/img/arrowRIGHT.png
new file mode 100644
index 0000000..563b1b9
Binary files /dev/null and b/ProjectBomber/src/ProjectBomber/img/arrowRIGHT.png differ
diff --git a/ProjectBomber/src/ProjectBomber/img/arrowUP.png b/ProjectBomber/src/ProjectBomber/img/arrowUP.png
new file mode 100644
index 0000000..c5a432c
Binary files /dev/null and b/ProjectBomber/src/ProjectBomber/img/arrowUP.png differ