diff --git a/AirBomber/src/AirBomberPackage/CanvasMy.java b/AirBomber/src/AirBomberPackage/CanvasMy.java new file mode 100644 index 0000000..6557a30 --- /dev/null +++ b/AirBomber/src/AirBomberPackage/CanvasMy.java @@ -0,0 +1,31 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package AirBomberPackage; + +import javax.swing.*; +import java.awt.*; + +/** + * + * @author Андрей + */ +public class CanvasMy extends JComponent { + public CanvasMy(){ + super(); + } + + private DrawingAirBomber _airBomber = null; + + public void setAirBomber(DrawingAirBomber _airBomber) { + this._airBomber = _airBomber; + } + + @Override + public void paintComponent(Graphics g){ + super.paintComponent(g); + Graphics2D g2d = (Graphics2D) g; + if (_airBomber != null) _airBomber.DrawTransport(g2d); + } +} diff --git a/AirBomber/src/AirBomberPackage/Direction.java b/AirBomber/src/AirBomberPackage/Direction.java new file mode 100644 index 0000000..7c7d402 --- /dev/null +++ b/AirBomber/src/AirBomberPackage/Direction.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package AirBomberPackage; + +/** + * + * @author Андрей + */ +public enum Direction { + UP, + DOWN, + LEFT, + RIGHT +} diff --git a/AirBomber/src/AirBomberPackage/DrawingAirBomber.java b/AirBomber/src/AirBomberPackage/DrawingAirBomber.java new file mode 100644 index 0000000..7720f00 --- /dev/null +++ b/AirBomber/src/AirBomberPackage/DrawingAirBomber.java @@ -0,0 +1,224 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package AirBomberPackage; +import java.awt.*; +import java.util.Random; +/** + * + * @author Андрей + */ +public class DrawingAirBomber { + private EntityAirBomber AirBomber; + public DrawingEngines drawingEngines; + public float _startPosX; + public float _startPosY; + private Integer _pictureWidth = null; + private Integer _pictureHeight = null; + private static final int _airBomberWidth = 110; + private static final int _airBomberHeight = 100; + + public void Init(int speed, float weight, Color bodyColor, int numberOfEngines){ + AirBomber = new EntityAirBomber(); + drawingEngines = new DrawingEngines(); + AirBomber.Init(speed, weight, bodyColor); + System.out.println(numberOfEngines + ""); + drawingEngines.setNumberOfEngines(numberOfEngines); + } + + public EntityAirBomber getAirBomber() { + return AirBomber; + } + + public void SetPosition(int x, int y, int width, int height){ + _pictureWidth = width; + _pictureHeight = height; + if (_pictureWidth == null || _pictureHeight == null) + { + return; + } + Random rd = new Random(); + _startPosX = x + _airBomberWidth >= _pictureWidth ? rd.nextInt(0, _pictureWidth - 1 - _airBomberWidth) : x; + _startPosY = y + _airBomberHeight >= _pictureHeight ? rd.nextInt(0, _pictureHeight - 1 - _airBomberHeight) : y; + } + + public void MoveTransport(Direction direction) + { + if (_pictureWidth == null || _pictureHeight == null) + { + return; + } + switch (direction) + { + // вправо + case RIGHT: + if (_startPosX + _airBomberWidth + AirBomber.Step < _pictureWidth) + { + _startPosX += AirBomber.Step; + } + break; + //влево + case LEFT: + if (_startPosX - AirBomber.Step > 0) + { + _startPosX -= AirBomber.Step; + } + break; + //вверх + case UP: + if (_startPosY - AirBomber.Step > 0) + { + _startPosY -= AirBomber.Step; + } + break; + //вниз + case DOWN: + if (_startPosY + _airBomberHeight + AirBomber.Step < _pictureHeight) + { + _startPosY += AirBomber.Step; + } + break; + } + } + + public void DrawTransport(Graphics2D g) + { + if (_startPosX < 0 || _startPosY < 0 + || _pictureHeight == null || _pictureWidth == null) + { + return; + } + + int _startPosXInt = (int)_startPosX; + int _startPosYInt = (int)_startPosY; + + //отрисовка двигателей + drawingEngines.drawEngines(g, _startPosXInt, _startPosYInt, AirBomber.getBodyColor()); + + //отрисовка кабины + int[] cabinX = + { + _startPosXInt + 5, + _startPosXInt + 20, + _startPosXInt + 20 + }; + + int[] cabinY = + { + _startPosYInt + 50, + _startPosYInt + 40, + _startPosYInt + 60 + }; + + g.fillPolygon(cabinX, cabinY, cabinX.length); + g.setColor(AirBomber.getBodyColor()); + //отрисовка корпуса + g.fillRect(_startPosXInt + 20, _startPosYInt + 40, 90, 20); + + //отрисовка правого крыла + int[] rightWingX = + { + _startPosXInt + 50, + _startPosXInt + 50, + _startPosXInt + 60, + _startPosXInt + 70 + }; + + int[] rightWingY = + { + _startPosYInt + 40, + _startPosYInt, + _startPosYInt, + _startPosYInt + 40 + }; + + g.fillPolygon(rightWingX, rightWingY, rightWingX.length); + + //отрисовка левого крыла + int[] leftWingX = + { + _startPosXInt + 50, + _startPosXInt + 50, + _startPosXInt + 60, + _startPosXInt + 70 + }; + + int[] leftWingY = + { + _startPosYInt + 60, + _startPosYInt + 100, + _startPosYInt + 100, + _startPosYInt + 60 + }; + + g.fillPolygon(leftWingX, leftWingY, leftWingX.length); + + //отрисовка хвоста (справа) + int[] rightTailX = + { + _startPosXInt + 95, + _startPosXInt + 95, + _startPosXInt + 110, + _startPosXInt + 110 + }; + + int[] rightTailY = + { + _startPosYInt + 40, + _startPosYInt + 30, + _startPosYInt + 15, + _startPosYInt + 40 + }; + + g.fillPolygon(rightTailX, rightTailY, rightTailX.length); + + //отрисовка хвоста (слева) + int[] leftTailX = + { + _startPosXInt + 95, + _startPosXInt + 95, + _startPosXInt + 110, + _startPosXInt + 110 + }; + + int[] leftTailY = + { + _startPosYInt + 60, + _startPosYInt + 70, + _startPosYInt + 85, + _startPosYInt + 60 + }; + + g.fillPolygon(leftTailX, leftTailY, leftTailX.length); + + g.setColor(Color.BLACK); + + g.drawRect(_startPosXInt + 20, _startPosYInt + 40, 90, 20); + g.drawPolygon(rightWingX, rightWingY, rightWingX.length); + g.drawPolygon(leftWingX, leftWingY, leftWingX.length); + g.drawPolygon(rightTailX, rightTailY, rightTailX.length); + g.drawPolygon(leftTailX, leftTailY, leftTailX.length); + g.drawLine(_startPosXInt, _startPosYInt + 50, _startPosXInt + 5, _startPosYInt + 50); + } + + public void ChangeBorders(int width, int height) + { + _pictureWidth = width; + _pictureHeight = height; + if (_pictureWidth <= _airBomberWidth || _pictureHeight <= _airBomberHeight) + { + _pictureWidth = null; + _pictureHeight = null; + return; + } + if (_startPosX + _airBomberWidth > _pictureWidth) + { + _startPosX = _pictureWidth - _airBomberWidth; + } + if (_startPosY + _airBomberHeight > _pictureHeight) + { + _startPosY = _pictureHeight - _airBomberHeight; + } + } +} diff --git a/AirBomber/src/AirBomberPackage/DrawingEngines.java b/AirBomber/src/AirBomberPackage/DrawingEngines.java new file mode 100644 index 0000000..53e529f --- /dev/null +++ b/AirBomber/src/AirBomberPackage/DrawingEngines.java @@ -0,0 +1,61 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package AirBomberPackage; + +import java.awt.Graphics2D; +import java.awt.Color; + +/** + * + * @author Андрей + */ +public class DrawingEngines { + private Engines engines = null; + private int numberOfEngines; + + public int getNumberOfEngines() { + return numberOfEngines; + } + + public void setNumberOfEngines(int numberOfEngines) { + if (numberOfEngines != 2 && numberOfEngines != 4 && numberOfEngines != 6) return; + this.numberOfEngines = numberOfEngines; + switch (this.numberOfEngines) { + case 2: + engines = Engines.TWO; + break; + case 4: + engines = Engines.FOUR; + break; + case 6: + engines = Engines.SIX; + break; + } + } + + private void drawEngine(Graphics2D g, int startPosX, int startPosY, int yOffset, Color bodyColor){ + g.setColor(bodyColor); + g.fillRect(startPosX + 45, startPosY + 40 + yOffset, 5, 5); + g.setColor(Color.BLACK); + g.drawRect(startPosX + 45, startPosY + 40 + yOffset, 5, 5); + } + + public void drawEngines(Graphics2D g, int startPosX, int startPosY, Color bodyColor){ + if (engines == null) return; + + switch (engines) { + case SIX: + drawEngine(g, startPosX, startPosY, -5 - 5 - 20, bodyColor); + drawEngine(g, startPosX, startPosY, 20 + 5 + 20, bodyColor); + case FOUR: + drawEngine(g, startPosX, startPosY, -5 - 5 - 10, bodyColor); + drawEngine(g, startPosX, startPosY, 20 + 5 + 10, bodyColor); + case TWO: + drawEngine(g, startPosX, startPosY, -5 - 5, bodyColor); + drawEngine(g, startPosX, startPosY, 20 + 5, bodyColor); + break; + } + } +} diff --git a/AirBomber/src/AirBomberPackage/Engines.java b/AirBomber/src/AirBomberPackage/Engines.java new file mode 100644 index 0000000..4fa9b8b --- /dev/null +++ b/AirBomber/src/AirBomberPackage/Engines.java @@ -0,0 +1,15 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package AirBomberPackage; + +/** + * + * @author Андрей + */ +public enum Engines { + TWO, + FOUR, + SIX +} diff --git a/AirBomber/src/AirBomberPackage/EntityAirBomber.java b/AirBomber/src/AirBomberPackage/EntityAirBomber.java new file mode 100644 index 0000000..d72ade4 --- /dev/null +++ b/AirBomber/src/AirBomberPackage/EntityAirBomber.java @@ -0,0 +1,43 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package AirBomberPackage; +import java.awt.Color; +import java.util.Random; + +/** + * + * @author Андрей + */ +public class EntityAirBomber { + private int Speed; + + private float Weight; + + private Color BodyColor; + + public float Step; + + public int getSpeed() { + return Speed; + } + + public float getWeight() { + return Weight; + } + + public Color getBodyColor() { + return BodyColor; + } + + + + public void Init(int speed, float weight, Color bodyColor){ + Random rnd = new Random(); + Speed = speed <= 0 ? rnd.nextInt(50, 150) : speed; + Weight = weight <= 0 ? rnd.nextInt(40, 70) : weight; + Step = Speed * 100 / Weight; + BodyColor = bodyColor; + } +} diff --git a/AirBomber/src/AirBomberPackage/JFrameAirBomber.form b/AirBomber/src/AirBomberPackage/JFrameAirBomber.form index 769eecd..527555d 100644 --- a/AirBomber/src/AirBomberPackage/JFrameAirBomber.form +++ b/AirBomber/src/AirBomberPackage/JFrameAirBomber.form @@ -3,6 +3,16 @@
+ + + + + + + + + + @@ -23,13 +33,191 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AirBomber/src/AirBomberPackage/JFrameAirBomber.java b/AirBomber/src/AirBomberPackage/JFrameAirBomber.java index 57162eb..e970014 100644 --- a/AirBomber/src/AirBomberPackage/JFrameAirBomber.java +++ b/AirBomber/src/AirBomberPackage/JFrameAirBomber.java @@ -3,6 +3,9 @@ * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template */ package AirBomberPackage; +import java.awt.*; +import javax.swing.*; +import java.util.Random; /** * @@ -16,6 +19,8 @@ public class JFrameAirBomber extends javax.swing.JFrame { public JFrameAirBomber() { initComponents(); } + + private DrawingAirBomber _airBomber; /** * This method is called from within the constructor to initialize the form. @@ -26,22 +31,180 @@ public class JFrameAirBomber extends javax.swing.JFrame { // //GEN-BEGIN:initComponents private void initComponents() { + createAirBomberButton = new javax.swing.JButton(); + leftButton = new javax.swing.JButton(); + downButton = new javax.swing.JButton(); + rightButton = new javax.swing.JButton(); + upButton = new javax.swing.JButton(); + statusLabel = new javax.swing.JLabel(); + airBomberCanvas = new AirBomberPackage.CanvasMy(); + jLabelEngines = new javax.swing.JLabel(); + jComboBoxEngines = new javax.swing.JComboBox<>(); + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("Бомбардировщик"); + setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N + setPreferredSize(new java.awt.Dimension(700, 400)); + setSize(new java.awt.Dimension(700, 400)); + + createAirBomberButton.setText("Создать"); + createAirBomberButton.setName("createAirBomberButton"); // NOI18N + createAirBomberButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + createAirBomberButtonActionPerformed(evt); + } + }); + + leftButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/AirBomberPackage/arrowLeft.png"))); // NOI18N + leftButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); + leftButton.setMaximumSize(new java.awt.Dimension(30, 30)); + leftButton.setMinimumSize(new java.awt.Dimension(30, 30)); + leftButton.setName("buttonLeft"); // NOI18N + leftButton.setPreferredSize(new java.awt.Dimension(30, 30)); + leftButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + moveButtonActionPerformed(evt); + } + }); + + downButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/AirBomberPackage/arrowDown.png"))); // NOI18N + downButton.setMaximumSize(new java.awt.Dimension(30, 30)); + downButton.setMinimumSize(new java.awt.Dimension(30, 30)); + downButton.setName("buttonDown"); // NOI18N + downButton.setPreferredSize(new java.awt.Dimension(30, 30)); + downButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + moveButtonActionPerformed(evt); + } + }); + + rightButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/AirBomberPackage/arrowRight.png"))); // NOI18N + rightButton.setMaximumSize(new java.awt.Dimension(30, 30)); + rightButton.setMinimumSize(new java.awt.Dimension(30, 30)); + rightButton.setName("buttonRight"); // NOI18N + rightButton.setPreferredSize(new java.awt.Dimension(30, 30)); + rightButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + moveButtonActionPerformed(evt); + } + }); + + upButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/AirBomberPackage/arrowUp.png"))); // NOI18N + upButton.setMaximumSize(new java.awt.Dimension(30, 30)); + upButton.setMinimumSize(new java.awt.Dimension(30, 30)); + upButton.setName("buttonUp"); // NOI18N + upButton.setPreferredSize(new java.awt.Dimension(30, 30)); + upButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + moveButtonActionPerformed(evt); + } + }); + + statusLabel.setText("Скорость: Вес: Цвет: Двигатели:"); + statusLabel.setMinimumSize(new java.awt.Dimension(0, 0)); + + airBomberCanvas.addComponentListener(new java.awt.event.ComponentAdapter() { + public void componentResized(java.awt.event.ComponentEvent evt) { + airBomberCanvasComponentResized(evt); + } + }); + + jLabelEngines.setText("Количество двигателей: "); + + jComboBoxEngines.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Два", "Четыре", "Шесть" })); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 400, Short.MAX_VALUE) + .addComponent(statusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabelEngines) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboBoxEngines, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(createAirBomberButton)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 369, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(upButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addComponent(leftButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(downButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(rightButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(17, 17, 17)) + .addComponent(airBomberCanvas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 300, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(airBomberCanvas, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabelEngines, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jComboBoxEngines, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(createAirBomberButton, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(upButton, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(leftButton, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(downButton, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(rightButton, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(statusLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)) ); pack(); }// //GEN-END:initComponents + private void createAirBomberButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createAirBomberButtonActionPerformed + Random rnd = new Random(); + _airBomber = new DrawingAirBomber(); + _airBomber.Init(rnd.nextInt(100, 300), rnd.nextInt(1000, 2000), new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256)), (jComboBoxEngines.getSelectedIndex() + 1) * 2); + System.out.println(((jComboBoxEngines.getSelectedIndex() + 1) * 2) + ""); + _airBomber.SetPosition(rnd.nextInt(10, 100), rnd.nextInt(10, 100), airBomberCanvas.getWidth(), airBomberCanvas.getHeight()); + statusLabel.setText("Скорость: " + _airBomber.getAirBomber().getSpeed() + " Вес: " + (int) _airBomber.getAirBomber().getWeight() + " Цвет: " + _airBomber.getAirBomber().getBodyColor() + " Двигатели: " + _airBomber.drawingEngines.getNumberOfEngines()); + airBomberCanvas.setAirBomber(_airBomber); + Draw(); + }//GEN-LAST:event_createAirBomberButtonActionPerformed + + private void moveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveButtonActionPerformed + if (_airBomber == null) return; + String name = ((JButton) evt.getSource()).getName(); + switch (name) + { + case "buttonUp": + _airBomber.MoveTransport(Direction.UP); + break; + case "buttonDown": + _airBomber.MoveTransport(Direction.DOWN); + break; + case "buttonLeft": + _airBomber.MoveTransport(Direction.LEFT); + break; + case "buttonRight": + _airBomber.MoveTransport(Direction.RIGHT); + break; + } + Draw(); + }//GEN-LAST:event_moveButtonActionPerformed + + private void airBomberCanvasComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_airBomberCanvasComponentResized + if (_airBomber == null) return; + _airBomber.ChangeBorders(airBomberCanvas.getWidth(), airBomberCanvas.getHeight()); + }//GEN-LAST:event_airBomberCanvasComponentResized + + private void Draw(){ + airBomberCanvas.repaint(); + } + /** * @param args the command line arguments */ @@ -78,5 +241,14 @@ public class JFrameAirBomber extends javax.swing.JFrame { } // Variables declaration - do not modify//GEN-BEGIN:variables + private AirBomberPackage.CanvasMy airBomberCanvas; + private javax.swing.JButton createAirBomberButton; + private javax.swing.JButton downButton; + private javax.swing.JComboBox jComboBoxEngines; + private javax.swing.JLabel jLabelEngines; + private javax.swing.JButton leftButton; + private javax.swing.JButton rightButton; + private javax.swing.JLabel statusLabel; + private javax.swing.JButton upButton; // End of variables declaration//GEN-END:variables } diff --git a/AirBomber/src/AirBomberPackage/arrowDown.png b/AirBomber/src/AirBomberPackage/arrowDown.png new file mode 100644 index 0000000..7aa9455 Binary files /dev/null and b/AirBomber/src/AirBomberPackage/arrowDown.png differ diff --git a/AirBomber/src/AirBomberPackage/arrowLeft.png b/AirBomber/src/AirBomberPackage/arrowLeft.png new file mode 100644 index 0000000..8853e48 Binary files /dev/null and b/AirBomber/src/AirBomberPackage/arrowLeft.png differ diff --git a/AirBomber/src/AirBomberPackage/arrowRight.png b/AirBomber/src/AirBomberPackage/arrowRight.png new file mode 100644 index 0000000..4cfbcce Binary files /dev/null and b/AirBomber/src/AirBomberPackage/arrowRight.png differ diff --git a/AirBomber/src/AirBomberPackage/arrowUp.png b/AirBomber/src/AirBomberPackage/arrowUp.png new file mode 100644 index 0000000..c5c08cc Binary files /dev/null and b/AirBomber/src/AirBomberPackage/arrowUp.png differ