diff --git a/DrawingAircraft.java b/DrawingAircraft.java index c7011d0..48b301a 100644 --- a/DrawingAircraft.java +++ b/DrawingAircraft.java @@ -1,8 +1,10 @@ import java.awt.*; +import java.util.Random; class DrawingAircraft { public EntityAircraft AirFighter; + public DrawingEngines drawingEngines = new DrawingEngines(); private float _startPosX; private float _startPosY; @@ -15,8 +17,11 @@ class DrawingAircraft public void Init(int speed, float weight, Color bodyColor) { + Random rnd = new Random(); + AirFighter = new EntityAircraft(); AirFighter.Init(speed, weight, bodyColor); + drawingEngines.Init(rnd.nextInt(1, 8), bodyColor); } public void SetPosition(int x, int y, int width, int height) @@ -120,6 +125,8 @@ class DrawingAircraft g.drawPolygon(wingTop); g.drawPolygon(wingBottom); g.drawRect((int)_startPosX, (int)_startPosY + 70, 160, 26); + + drawingEngines.draw(g, (int)_startPosX, (int)_startPosY); } public void ChangeBorders(int width, int height) diff --git a/DrawingEngines.java b/DrawingEngines.java new file mode 100644 index 0000000..9878094 --- /dev/null +++ b/DrawingEngines.java @@ -0,0 +1,30 @@ +import java.awt.*; + +public class DrawingEngines { + private EnginesCount enginesCount; + private Color color; + + public void Init(int count, Color bodyColor) { + if(count <= 2) enginesCount = EnginesCount.Two; + else if(count >= 6) enginesCount = EnginesCount.Six; + else enginesCount = EnginesCount.Four; + + color = bodyColor; + } + + public void draw(Graphics2D g, int startPosX, int startPosY) { + g.setPaint(color); + g.fillOval(startPosX + 90, startPosY + 10, 30, 15); + g.fillOval(startPosX + 90, startPosY + 141, 30, 15); + + if(enginesCount == EnginesCount.Two) return; + + g.fillOval(startPosX + 90, startPosY + 30, 30, 15); + g.fillOval(startPosX + 90, startPosY + 121, 30, 15); + + if(enginesCount == EnginesCount.Four) return; + + g.fillOval(startPosX + 90, startPosY + 50, 30, 15); + g.fillOval(startPosX + 90, startPosY + 101, 30, 15); + } +} diff --git a/EnginesCount.java b/EnginesCount.java new file mode 100644 index 0000000..dbea801 --- /dev/null +++ b/EnginesCount.java @@ -0,0 +1,5 @@ +public enum EnginesCount { + Two, + Four, + Six +} diff --git a/FormAircraft.form b/FormAircraft.form index fedb5cb..ee165ee 100644 --- a/FormAircraft.form +++ b/FormAircraft.form @@ -1,6 +1,7 @@
diff --git a/Resources/down.png b/Resources/down.png new file mode 100644 index 0000000..7500783 Binary files /dev/null and b/Resources/down.png differ diff --git a/Resources/left.png b/Resources/left.png new file mode 100644 index 0000000..c4ef54a Binary files /dev/null and b/Resources/left.png differ diff --git a/Resources/right.png b/Resources/right.png new file mode 100644 index 0000000..7851a8e Binary files /dev/null and b/Resources/right.png differ diff --git a/Resources/up.png b/Resources/up.png new file mode 100644 index 0000000..7424b89 Binary files /dev/null and b/Resources/up.png differ