diff --git a/DrawEngines.java b/DrawEngines.java new file mode 100644 index 0000000..ba311df --- /dev/null +++ b/DrawEngines.java @@ -0,0 +1,36 @@ +import java.awt.*; + +public class DrawEngines +{ + private Engines numEngines; + + public void SetNumEngines(int i) { numEngines = Engines.GetNumEngines(i); } + + public void DrawningEngines(float _startPosX, float _startPosY, Graphics2D g2d, int _airBomberWidth, int _airBomberHeight) + { + switch(numEngines) + { + case TwoEngines: + g2d.fillRect((int)_startPosX + _airBomberWidth / 2 - 20, (int)_startPosY + _airBomberHeight / 2 - 20, 20, 10); + g2d.fillRect((int)_startPosX + _airBomberWidth / 2 - 20, (int)_startPosY + _airBomberHeight / 2 + 10, 20, 10); + break; + case FourEngines: + g2d.fillRect((int)_startPosX + _airBomberWidth / 2 - 20, (int)_startPosY + _airBomberHeight / 2 - 20, 20, 10); + g2d.fillRect((int)_startPosX + _airBomberWidth / 2 - 20, (int)_startPosY + _airBomberHeight / 2 + 10, 20, 10); + + g2d.fillRect((int)_startPosX + _airBomberWidth / 2 - 15, (int)_startPosY + _airBomberHeight / 2 - 35, 15, 10); + g2d.fillRect((int)_startPosX + _airBomberWidth / 2 - 15, (int)_startPosY + _airBomberHeight / 2 + 25, 15, 10); + break; + case SixEngines: + g2d.fillRect((int)_startPosX + _airBomberWidth / 2 - 20, (int)_startPosY + _airBomberHeight / 2 - 20, 20, 10); + g2d.fillRect((int)_startPosX + _airBomberWidth / 2 - 20, (int)_startPosY + _airBomberHeight / 2 + 10, 20, 10); + + g2d.fillRect((int)_startPosX + _airBomberWidth / 2 - 15, (int)_startPosY + _airBomberHeight / 2 - 35, 15, 10); + g2d.fillRect((int)_startPosX + _airBomberWidth / 2 - 15, (int)_startPosY + _airBomberHeight / 2 + 25, 15, 10); + + g2d.fillRect((int)_startPosX + _airBomberWidth / 2 - 10, (int)_startPosY + _airBomberHeight / 2 - 50, 10, 10); + g2d.fillRect((int)_startPosX + _airBomberWidth / 2 - 10, (int)_startPosY + _airBomberHeight / 2 + 40, 10, 10); + break; + } + } +} diff --git a/DrawningBomber.java b/DrawningBomber.java index 0e75f41..395a0aa 100644 --- a/DrawningBomber.java +++ b/DrawningBomber.java @@ -13,10 +13,15 @@ public class DrawningBomber extends JPanel private final int _airBomberWidth = 100; private final int _airBomberHeight = 100; + private int NumEngines = 1; + private DrawEngines drawEngines = new DrawEngines(); + public void Init(int speed, float weight, Color bodyColor) { AirBomber = new EntityAirBomber(); AirBomber.Init(speed, weight, bodyColor); + Random random = new Random(); + drawEngines.SetNumEngines(random.nextInt(1, 4)); } public void SetPosition(int x, int y, int width, int height) @@ -113,7 +118,7 @@ public class DrawningBomber extends JPanel (int)(_startPosY + _airBomberHeight), (int)(_startPosY + _airBomberHeight)}; - g.fillPolygon(xPos, yPos, xPos.length); + g2d.fillPolygon(xPos, yPos, xPos.length); xPos = new int[] { (int)(_startPosX + 20), @@ -127,7 +132,7 @@ public class DrawningBomber extends JPanel (int)(_startPosY + _airBomberHeight / 2 + 5), (int)(_startPosY + _airBomberHeight / 2 + 5)}; - g.fillPolygon(xPos, yPos, xPos.length); + g2d.fillPolygon(xPos, yPos, xPos.length); xPos = new int[] { (int)(_startPosX), @@ -139,7 +144,8 @@ public class DrawningBomber extends JPanel (int)(_startPosY + _airBomberHeight / 2 - 5), (int)(_startPosY + _airBomberHeight / 2 + 5)}; - g.fillPolygon(xPos, yPos, xPos.length); + g2d.fillPolygon(xPos, yPos, xPos.length); + drawEngines.DrawningEngines(_startPosX, _startPosY, g2d, _airBomberWidth, _airBomberHeight); } public void ChangeBorders(int width, int height) diff --git a/Engines.java b/Engines.java new file mode 100644 index 0000000..2d2e3a4 --- /dev/null +++ b/Engines.java @@ -0,0 +1,24 @@ +public enum Engines +{ + TwoEngines(1), + FourEngines(2), + SixEngines(6); + + Engines(int i) { + + } + + public static Engines GetNumEngines(int i) + { + switch(i) + { + case 1: + return TwoEngines; + case 2: + return FourEngines; + case 3: + return SixEngines; + } + return null; + } +}