Изменил(а) на 'DrawingPlane.java'

This commit is contained in:
devil_1nc 2022-11-08 14:53:44 +04:00
parent 968bae0c5b
commit 5324095e2a

View File

@ -1,11 +1,6 @@
import java.awt.*; import java.awt.*;
public class DrawingPlane { public class DrawingPlane {
public EntityPlane Plane; public EntityPlane Plane;
public EntityPlane getPlane()
{
return Plane;
}
private float _startPosX; private float _startPosX;
private float _startPosY; private float _startPosY;
private Integer _pictureWidth = null; private Integer _pictureWidth = null;
@ -13,9 +8,12 @@ public class DrawingPlane {
private final int _planeWidth = 125; private final int _planeWidth = 125;
private final int _planeHeight = 45; private final int _planeHeight = 45;
public void Init(int speed, float weight, Color bodyColor, EntityPlane entity) public DrawingIlum drawingilum;
public void Init(int speed, float weight, Color bodyColor, int ilNum, EntityPlane entity)
{ {
Plane = new EntityPlane(); Plane = entity;
drawingilum = new DrawingIlum();
drawingilum.Init(ilNum, bodyColor);
Plane.Init(speed, weight, bodyColor); Plane.Init(speed, weight, bodyColor);
} }
@ -48,20 +46,23 @@ public class DrawingPlane {
{ {
_startPosX += Plane.Step(); _startPosX += Plane.Step();
} }
else _startPosX = _pictureWidth - _planeWidth;
break; break;
//влево //влево
case Left: case Left:
if (_startPosX - Plane.Step() > 0) if (_startPosX - Plane.Step() >= 0)
{ {
_startPosX -= Plane.Step(); _startPosX -= Plane.Step();
} }
else _startPosX = 0;
break; break;
//вверх //вверх
case Up: case Up:
if (_startPosY - Plane.Step() > 0) if (_startPosY - Plane.Step() >= 0)
{ {
_startPosY -= Plane.Step(); _startPosY -= Plane.Step();
} }
else _startPosY = 0;
break; break;
//вниз //вниз
@ -70,18 +71,18 @@ public class DrawingPlane {
{ {
_startPosY += Plane.Step(); _startPosY += Plane.Step();
} }
else _startPosY = _pictureHeight - _planeWidth;
break; break;
} }
} }
public void DrawTransport(Graphics g) public void DrawTransport(Graphics2D g)
{ {
if (_startPosX < 0 || _startPosY < 0 if (_startPosX < 0 || _startPosY < 0
|| _pictureHeight == null|| _pictureWidth == 0) || _pictureHeight == null|| _pictureWidth == 0)
{ {
return; return;
} }
g.setColor(Color.BLACK); g.setColor(Color.black);
g.drawOval((int)_startPosX, (int)_startPosY + 20, 20, 20); g.drawOval((int)_startPosX, (int)_startPosY + 20, 20, 20);
g.drawRect((int)_startPosX + 8, (int)_startPosY + 20, 100, 20); g.drawRect((int)_startPosX + 8, (int)_startPosY + 20, 100, 20);
@ -120,6 +121,12 @@ public class DrawingPlane {
new int[] {(int)_startPosY + 20, (int)_startPosY, (int)_startPosY + 20}, 3 new int[] {(int)_startPosY + 20, (int)_startPosY, (int)_startPosY + 20}, 3
); );
g.setColor(Color.blue); g.setColor(Color.blue);
for (int tempX = 98; tempX > 38; tempX -= 6) {
g.fillOval((int) _startPosX + tempX, (int)_startPosY + 20, 4, 4);
}
drawingilum.DrawIl((int)_startPosX, (int)_startPosY, g);
g.fillPolygon g.fillPolygon
( (
new int[] {(int)_startPosX + 108, (int)_startPosX + 125, (int)_startPosX + 108}, new int[] {(int)_startPosX + 108, (int)_startPosX + 125, (int)_startPosX + 108},
@ -138,9 +145,9 @@ public class DrawingPlane {
g.fillOval((int)_startPosX, (int)_startPosY + 18, 7, 7); g.fillOval((int)_startPosX, (int)_startPosY + 18, 7, 7);
g.fillOval((int)_startPosX + 20, (int)_startPosY + 18, 7, 7); g.fillOval((int)_startPosX + 20, (int)_startPosY + 18, 7, 7);
g.fillRect((int)_startPosX + 41, (int)_startPosY + 28, 42, 4); g.fillRect((int)_startPosX + 41, (int)_startPosY + 34, 42, 4);
g.fillOval((int)_startPosX + 39, (int)_startPosY + 28, 4, 4); g.fillOval((int)_startPosX + 39, (int)_startPosY + 34, 4, 4);
g.fillOval((int)_startPosX + 81, (int)_startPosY + 28, 4, 4); g.fillOval((int)_startPosX + 81, (int)_startPosY + 34, 4, 4);
} }
public void ChangeBorders(int width, int height) public void ChangeBorders(int width, int height)