Dolgov D.A. Hard Lab Work 1 #1

Closed
devil_1nc wants to merge 6 commits from LabWork01 into master
Showing only changes of commit 5324095e2a - Show all commits

View File

@ -1,11 +1,6 @@
import java.awt.*;
public class DrawingPlane {
public EntityPlane Plane;
public EntityPlane getPlane()
{
return Plane;
}
private float _startPosX;
private float _startPosY;
private Integer _pictureWidth = null;
@ -13,9 +8,12 @@ public class DrawingPlane {
private final int _planeWidth = 125;
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);
}
@ -48,20 +46,23 @@ public class DrawingPlane {
{
_startPosX += Plane.Step();
}
else _startPosX = _pictureWidth - _planeWidth;
break;
//влево
case Left:
if (_startPosX - Plane.Step() > 0)
if (_startPosX - Plane.Step() >= 0)
{
_startPosX -= Plane.Step();
}
else _startPosX = 0;
break;
//вверх
case Up:
if (_startPosY - Plane.Step() > 0)
if (_startPosY - Plane.Step() >= 0)
{
_startPosY -= Plane.Step();
}
else _startPosY = 0;
break;
//вниз
@ -70,18 +71,18 @@ public class DrawingPlane {
{
_startPosY += Plane.Step();
}
else _startPosY = _pictureHeight - _planeWidth;
break;
}
}
public void DrawTransport(Graphics g)
public void DrawTransport(Graphics2D g)
{
if (_startPosX < 0 || _startPosY < 0
|| _pictureHeight == null|| _pictureWidth == 0)
{
return;
}
g.setColor(Color.BLACK);
g.setColor(Color.black);
g.drawOval((int)_startPosX, (int)_startPosY + 20, 20, 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
);
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
(
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 + 20, (int)_startPosY + 18, 7, 7);
g.fillRect((int)_startPosX + 41, (int)_startPosY + 28, 42, 4);
g.fillOval((int)_startPosX + 39, (int)_startPosY + 28, 4, 4);
g.fillOval((int)_startPosX + 81, (int)_startPosY + 28, 4, 4);
g.fillRect((int)_startPosX + 41, (int)_startPosY + 34, 42, 4);
g.fillOval((int)_startPosX + 39, (int)_startPosY + 34, 4, 4);
g.fillOval((int)_startPosX + 81, (int)_startPosY + 34, 4, 4);
}
public void ChangeBorders(int width, int height)