With dopAsk

This commit is contained in:
Артём Алейкин 2022-11-29 20:50:45 +04:00
parent 091005867d
commit 3166c0b054
3 changed files with 69 additions and 3 deletions

36
DrawEngines.java Normal file
View File

@ -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;
}
}
}

View File

@ -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)

24
Engines.java Normal file
View File

@ -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;
}
}