Добавлен интерфейс и редактированы классы Drawing
This commit is contained in:
parent
2f1be18356
commit
049a4df69f
@ -4,8 +4,9 @@ import java.awt.*;
|
|||||||
|
|
||||||
public class DrawingPlane {
|
public class DrawingPlane {
|
||||||
public EntityPlane EntityPlane;
|
public EntityPlane EntityPlane;
|
||||||
private int _pictureWidth;
|
protected DrawingEngines _drawingEngines;
|
||||||
private int _pictureHeight;
|
protected int _pictureWidth;
|
||||||
|
protected int _pictureHeight;
|
||||||
protected int _startPosX;
|
protected int _startPosX;
|
||||||
protected int _startPosY;
|
protected int _startPosY;
|
||||||
protected int _planeWidth = 110;
|
protected int _planeWidth = 110;
|
||||||
@ -47,6 +48,9 @@ public class DrawingPlane {
|
|||||||
_planeHeight = planeHeight;
|
_planeHeight = planeHeight;
|
||||||
EntityPlane = new EntityPlane(speed, weight, bodyColor);
|
EntityPlane = new EntityPlane(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
|
public void SetEnginesCount(int enginesCount) {
|
||||||
|
_drawingEngines.SetEnumEnginesCount(enginesCount);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean CanMove(EnumDirectionType direction) {
|
public boolean CanMove(EnumDirectionType direction) {
|
||||||
if (EntityPlane == null) {
|
if (EntityPlane == null) {
|
||||||
@ -114,12 +118,13 @@ public class DrawingPlane {
|
|||||||
|
|
||||||
Color bodyColor = EntityPlane.BodyColor;
|
Color bodyColor = EntityPlane.BodyColor;
|
||||||
Color blackColor = Color.BLACK;
|
Color blackColor = Color.BLACK;
|
||||||
Color redColor = Color.RED;
|
|
||||||
|
|
||||||
// Длина фюзеляжа
|
// Длина фюзеляжа
|
||||||
int bodyHeight = _planeHeight / 9;
|
int bodyHeight = _planeHeight / 9;
|
||||||
int bodyWidth = _planeWidth - _planeWidth / 8;
|
int bodyWidth = _planeWidth - _planeWidth / 8;
|
||||||
|
|
||||||
|
_drawingEngines.DrawEngines(g, bodyColor, _startPosX, _startPosY, _planeWidth, _planeHeight);
|
||||||
|
|
||||||
// Рисуем нос
|
// Рисуем нос
|
||||||
Polygon cockPitPolygon = new Polygon();
|
Polygon cockPitPolygon = new Polygon();
|
||||||
cockPitPolygon.addPoint(_startPosX, _startPosY + _planeHeight / 2);
|
cockPitPolygon.addPoint(_startPosX, _startPosY + _planeHeight / 2);
|
||||||
|
@ -2,113 +2,49 @@ package ProjectStormtrooper;
|
|||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class DrawingStormtrooper {
|
public class DrawingStormtrooper extends DrawingPlane {
|
||||||
public EntityStormtrooper EntityStormtrooper;
|
public DrawingStormtrooper(int speed, double weight, Color bodyColor,
|
||||||
private DrawingEngines _drawingEngines;
|
Color additionalColor, boolean rockets, boolean bombs,
|
||||||
private int _pictureWidth;
|
int width, int height) {
|
||||||
private int _pictureHeight;
|
super(speed, weight, bodyColor, width, height, 140, 90);
|
||||||
private int _startPosX;
|
if (EntityPlane != null) {
|
||||||
private int _startPosY;
|
EntityPlane = new EntityStormtrooper(speed, weight, bodyColor, additionalColor, rockets, bombs);
|
||||||
private final int _stormtrooperWidth = 110;
|
|
||||||
private final int _stormtrooperHeight = 110;
|
|
||||||
|
|
||||||
public boolean Init(int speed, double weight, Color bodyColor,
|
|
||||||
Color additionalColor, boolean rockets, boolean bombs,
|
|
||||||
int width, int height) {
|
|
||||||
if (width < _stormtrooperWidth && height < _stormtrooperHeight) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
_pictureWidth = width;
|
|
||||||
_pictureHeight = height;
|
|
||||||
_drawingEngines = new DrawingEngines();
|
|
||||||
EntityStormtrooper = new EntityStormtrooper();
|
|
||||||
EntityStormtrooper.Init(speed, weight, bodyColor, additionalColor, rockets, bombs);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetEnginesCount(int enginesCount) {
|
|
||||||
_drawingEngines.SetEnumEnginesCount(enginesCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetPosition(int x, int y) {
|
|
||||||
if (x < 0) {
|
|
||||||
x = 0;
|
|
||||||
} else if (x > _pictureWidth - _stormtrooperWidth) {
|
|
||||||
x = _pictureWidth - _stormtrooperWidth;
|
|
||||||
}
|
|
||||||
_startPosX = x;
|
|
||||||
|
|
||||||
if (y < 0) {
|
|
||||||
y = 0;
|
|
||||||
} else if (y > _pictureHeight - _stormtrooperHeight) {
|
|
||||||
y = _pictureHeight - _stormtrooperHeight;
|
|
||||||
}
|
|
||||||
_startPosY = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MoveTransport(EnumDirectionType direction) {
|
|
||||||
if (EntityStormtrooper == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (direction) {
|
|
||||||
case Up -> {
|
|
||||||
if (_startPosY - EntityStormtrooper.Step() >= 0) {
|
|
||||||
_startPosY -= (int) EntityStormtrooper.Step();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case Down -> {
|
|
||||||
if (_startPosY + _stormtrooperHeight + EntityStormtrooper.Step() <= _pictureHeight) {
|
|
||||||
_startPosY += (int) EntityStormtrooper.Step();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case Left -> {
|
|
||||||
if (_startPosX - EntityStormtrooper.Step() >= 0) {
|
|
||||||
_startPosX -= (int) EntityStormtrooper.Step();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case Right -> {
|
|
||||||
if (_startPosX + _stormtrooperWidth + EntityStormtrooper.Step() <= _pictureWidth) {
|
|
||||||
_startPosX += (int) EntityStormtrooper.Step();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawTransport(Graphics g) {
|
public void DrawTransport(Graphics g) {
|
||||||
if (EntityStormtrooper == null) {
|
if (EntityPlane == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!(EntityPlane instanceof EntityStormtrooper entityStormtrooper)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Graphics2D g2d = (Graphics2D) g;
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
|
|
||||||
Color bodyColor = EntityStormtrooper.BodyColor;
|
int bodyHeight = _planeHeight / 9;
|
||||||
Color additionalColor = EntityStormtrooper.AdditionalColor;
|
|
||||||
Color blackColor = Color.BLACK;
|
Color blackColor = Color.BLACK;
|
||||||
Color redColor = Color.RED;
|
Color redColor = Color.RED;
|
||||||
|
Color additionalColor = entityStormtrooper.AdditionalColor;
|
||||||
_drawingEngines.DrawEngines(g, additionalColor, _startPosX, _startPosY, _stormtrooperWidth, _stormtrooperHeight);
|
|
||||||
|
|
||||||
// Длина фюзеляжа
|
|
||||||
int bodyHeight = _stormtrooperHeight / 9;
|
|
||||||
int bodyWidth = _stormtrooperWidth - _stormtrooperWidth / 8;
|
|
||||||
|
|
||||||
// Рисуем бомбы
|
// Рисуем бомбы
|
||||||
if (EntityStormtrooper.Bombs) {
|
if (entityStormtrooper.Bombs) {
|
||||||
Polygon bombTailPolygon = new Polygon();
|
Polygon bombTailPolygon = new Polygon();
|
||||||
bombTailPolygon.addPoint(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8 + bodyHeight * 3 - 5,
|
bombTailPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 8 + bodyHeight * 3 - 5,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight / 2 - _stormtrooperHeight / 3 + bodyHeight / 2);
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 - _planeHeight / 3 + bodyHeight / 2);
|
||||||
bombTailPolygon.addPoint(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8 + bodyHeight * 3 + 5,
|
bombTailPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 8 + bodyHeight * 3 + 5,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight / 2 - _stormtrooperHeight / 3 + bodyHeight / 2 - 5);
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 - _planeHeight / 3 + bodyHeight / 2 - 5);
|
||||||
bombTailPolygon.addPoint(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8 + bodyHeight * 3 + 5,
|
bombTailPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 8 + bodyHeight * 3 + 5,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight / 2 - _stormtrooperHeight / 3 + bodyHeight / 2 + 5);
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 - _planeHeight / 3 + bodyHeight / 2 + 5);
|
||||||
bombTailPolygon.addPoint(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8 + bodyHeight * 3 - 5,
|
bombTailPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 8 + bodyHeight * 3 - 5,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight / 2 - _stormtrooperHeight / 3 + bodyHeight / 2);
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 - _planeHeight / 3 + bodyHeight / 2);
|
||||||
|
|
||||||
g2d.setColor(additionalColor);
|
g2d.setColor(additionalColor);
|
||||||
g2d.fillPolygon(bombTailPolygon);
|
g2d.fillPolygon(bombTailPolygon);
|
||||||
g2d.setColor(blackColor);
|
g2d.setColor(blackColor);
|
||||||
g2d.drawPolygon(bombTailPolygon);
|
g2d.drawPolygon(bombTailPolygon);
|
||||||
|
|
||||||
bombTailPolygon.translate(0, (int) (_stormtrooperHeight - 2 * (_stormtrooperHeight / 2 - bodyHeight / 2 - _stormtrooperHeight / 3 + bodyHeight / 2 - 5) - bombTailPolygon.getBounds2D().getHeight()));
|
bombTailPolygon.translate(0, (int) (_planeHeight - 2 * (_planeHeight / 2 - bodyHeight / 2 - _planeHeight / 3 + bodyHeight / 2 - 5) - bombTailPolygon.getBounds2D().getHeight()));
|
||||||
|
|
||||||
g2d.setColor(additionalColor);
|
g2d.setColor(additionalColor);
|
||||||
g2d.fillPolygon(bombTailPolygon);
|
g2d.fillPolygon(bombTailPolygon);
|
||||||
@ -117,50 +53,50 @@ public class DrawingStormtrooper {
|
|||||||
|
|
||||||
g2d.setColor(additionalColor);
|
g2d.setColor(additionalColor);
|
||||||
g2d.fillOval(
|
g2d.fillOval(
|
||||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8,
|
_startPosX + _planeWidth / 2 - _planeWidth / 8,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight / 2 - _stormtrooperHeight / 3,
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 - _planeHeight / 3,
|
||||||
bodyHeight * 3,
|
bodyHeight * 3,
|
||||||
bodyHeight);
|
bodyHeight);
|
||||||
|
|
||||||
g2d.fillOval(
|
g2d.fillOval(
|
||||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8,
|
_startPosX + _planeWidth / 2 - _planeWidth / 8,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight / 2 + _stormtrooperHeight / 3,
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 + _planeHeight / 3,
|
||||||
bodyHeight * 3,
|
bodyHeight * 3,
|
||||||
bodyHeight);
|
bodyHeight);
|
||||||
|
|
||||||
g2d.setColor(blackColor);
|
g2d.setColor(blackColor);
|
||||||
g2d.drawOval(
|
g2d.drawOval(
|
||||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8,
|
_startPosX + _planeWidth / 2 - _planeWidth / 8,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight / 2 - _stormtrooperHeight / 3,
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 - _planeHeight / 3,
|
||||||
bodyHeight * 3,
|
bodyHeight * 3,
|
||||||
bodyHeight);
|
bodyHeight);
|
||||||
g2d.drawOval(
|
g2d.drawOval(
|
||||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 8,
|
_startPosX + _planeWidth / 2 - _planeWidth / 8,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight / 2 + _stormtrooperHeight / 3,
|
_startPosY + _planeHeight / 2 - bodyHeight / 2 + _planeHeight / 3,
|
||||||
bodyHeight * 3,
|
bodyHeight * 3,
|
||||||
bodyHeight);
|
bodyHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Рисуем ракеты
|
// Рисуем ракеты
|
||||||
if (EntityStormtrooper.Rockets) {
|
if (entityStormtrooper.Rockets) {
|
||||||
int rocketWidth = bodyHeight * 4;
|
int rocketWidth = bodyHeight * 4;
|
||||||
int rocketHeight = bodyHeight / 2;
|
int rocketHeight = bodyHeight / 2;
|
||||||
|
|
||||||
Polygon rocketCockPitPolygon = new Polygon();
|
Polygon rocketCockPitPolygon = new Polygon();
|
||||||
rocketCockPitPolygon.addPoint(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5 - rocketHeight,
|
rocketCockPitPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 5 - rocketHeight,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight - bodyHeight / 2 + rocketHeight / 2);
|
_startPosY + _planeHeight / 2 - bodyHeight - bodyHeight / 2 + rocketHeight / 2);
|
||||||
rocketCockPitPolygon.addPoint(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5,
|
rocketCockPitPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 5,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight - bodyHeight / 2);
|
_startPosY + _planeHeight / 2 - bodyHeight - bodyHeight / 2);
|
||||||
rocketCockPitPolygon.addPoint(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5,
|
rocketCockPitPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 5,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight - bodyHeight / 2 + rocketHeight);
|
_startPosY + _planeHeight / 2 - bodyHeight - bodyHeight / 2 + rocketHeight);
|
||||||
|
|
||||||
Polygon rocketTailPolygon = new Polygon();
|
Polygon rocketTailPolygon = new Polygon();
|
||||||
rocketTailPolygon.addPoint(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5 - rocketHeight + rocketWidth - 10,
|
rocketTailPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 5 - rocketHeight + rocketWidth - 10,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight - bodyHeight / 2 + rocketHeight / 2);
|
_startPosY + _planeHeight / 2 - bodyHeight - bodyHeight / 2 + rocketHeight / 2);
|
||||||
rocketTailPolygon.addPoint(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5 + rocketWidth,
|
rocketTailPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 5 + rocketWidth,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight * 2 + rocketHeight / 2);
|
_startPosY + _planeHeight / 2 - bodyHeight * 2 + rocketHeight / 2);
|
||||||
rocketTailPolygon.addPoint(_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5 + rocketWidth,
|
rocketTailPolygon.addPoint(_startPosX + _planeWidth / 2 - _planeWidth / 5 + rocketWidth,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight - bodyHeight / 2 + rocketHeight + bodyHeight / 2 - rocketHeight / 2);
|
_startPosY + _planeHeight / 2 - bodyHeight - bodyHeight / 2 + rocketHeight + bodyHeight / 2 - rocketHeight / 2);
|
||||||
|
|
||||||
g2d.setColor(redColor);
|
g2d.setColor(redColor);
|
||||||
g2d.fillPolygon(rocketCockPitPolygon);
|
g2d.fillPolygon(rocketCockPitPolygon);
|
||||||
@ -170,8 +106,8 @@ public class DrawingStormtrooper {
|
|||||||
g2d.setColor(blackColor);
|
g2d.setColor(blackColor);
|
||||||
g2d.fillPolygon(rocketTailPolygon);
|
g2d.fillPolygon(rocketTailPolygon);
|
||||||
|
|
||||||
rocketCockPitPolygon.translate(0, (int) (_stormtrooperHeight - 2 * (_stormtrooperHeight / 2 - bodyHeight - bodyHeight / 2) - rocketCockPitPolygon.getBounds2D().getHeight()));
|
rocketCockPitPolygon.translate(0, (int) (_planeHeight - 2 * (_planeHeight / 2 - bodyHeight - bodyHeight / 2) - rocketCockPitPolygon.getBounds2D().getHeight()));
|
||||||
rocketTailPolygon.translate(0, (int) (_stormtrooperHeight - 2 * (_stormtrooperHeight / 2 - bodyHeight * 2 + rocketHeight / 2) - rocketTailPolygon.getBounds2D().getHeight()));
|
rocketTailPolygon.translate(0, (int) (_planeHeight - 2 * (_planeHeight / 2 - bodyHeight * 2 + rocketHeight / 2) - rocketTailPolygon.getBounds2D().getHeight()));
|
||||||
|
|
||||||
g2d.setColor(redColor);
|
g2d.setColor(redColor);
|
||||||
g2d.fillPolygon(rocketCockPitPolygon);
|
g2d.fillPolygon(rocketCockPitPolygon);
|
||||||
@ -183,80 +119,32 @@ public class DrawingStormtrooper {
|
|||||||
|
|
||||||
g2d.setColor(additionalColor);
|
g2d.setColor(additionalColor);
|
||||||
g2d.fillRect(
|
g2d.fillRect(
|
||||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5,
|
_startPosX + _planeWidth / 2 - _planeWidth / 5,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight - bodyHeight / 2,
|
_startPosY + _planeHeight / 2 - bodyHeight - bodyHeight / 2,
|
||||||
rocketWidth,
|
rocketWidth,
|
||||||
rocketHeight);
|
rocketHeight);
|
||||||
|
|
||||||
|
|
||||||
g2d.fillRect(
|
g2d.fillRect(
|
||||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5,
|
_startPosX + _planeWidth / 2 - _planeWidth / 5,
|
||||||
_startPosY + _stormtrooperHeight / 2 + bodyHeight / 2 + bodyHeight / 2,
|
_startPosY + _planeHeight / 2 + bodyHeight / 2 + bodyHeight / 2,
|
||||||
rocketWidth,
|
rocketWidth,
|
||||||
rocketHeight);
|
rocketHeight);
|
||||||
|
|
||||||
g2d.setColor(blackColor);
|
g2d.setColor(blackColor);
|
||||||
g2d.drawRect(
|
g2d.drawRect(
|
||||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5,
|
_startPosX + _planeWidth / 2 - _planeWidth / 5,
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight - bodyHeight / 2,
|
_startPosY + _planeHeight / 2 - bodyHeight - bodyHeight / 2,
|
||||||
rocketWidth,
|
rocketWidth,
|
||||||
rocketHeight);
|
rocketHeight);
|
||||||
|
|
||||||
g2d.drawRect(
|
g2d.drawRect(
|
||||||
_startPosX + _stormtrooperWidth / 2 - _stormtrooperWidth / 5,
|
_startPosX + _planeWidth / 2 - _planeWidth / 5,
|
||||||
_startPosY + _stormtrooperHeight / 2 + bodyHeight / 2 + bodyHeight / 2,
|
_startPosY + _planeHeight / 2 + bodyHeight / 2 + bodyHeight / 2,
|
||||||
rocketWidth,
|
rocketWidth,
|
||||||
rocketHeight);
|
rocketHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Рисуем нос
|
super.DrawTransport(g);
|
||||||
Polygon cockPitPolygon = new Polygon();
|
|
||||||
cockPitPolygon.addPoint(_startPosX, _startPosY + _stormtrooperHeight / 2);
|
|
||||||
cockPitPolygon.addPoint(_startPosX + _stormtrooperWidth / 8, _startPosY + _stormtrooperHeight / 2 - bodyHeight / 2);
|
|
||||||
cockPitPolygon.addPoint(_startPosX + _stormtrooperWidth / 8, _startPosY + _stormtrooperHeight / 2 + bodyHeight / 2);
|
|
||||||
|
|
||||||
g2d.setColor(blackColor);
|
|
||||||
g2d.fillPolygon(cockPitPolygon);
|
|
||||||
|
|
||||||
// Рисуем крылья
|
|
||||||
Polygon wingsPolygon = new Polygon();
|
|
||||||
wingsPolygon.addPoint(_startPosX + _stormtrooperWidth / 2, _startPosY);
|
|
||||||
wingsPolygon.addPoint(_startPosX + _stormtrooperWidth / 2 + _stormtrooperWidth / 15, _startPosY);
|
|
||||||
wingsPolygon.addPoint(_startPosX + _stormtrooperWidth / 2 + _stormtrooperWidth / 6, _startPosY + _stormtrooperHeight / 2);
|
|
||||||
wingsPolygon.addPoint(_startPosX + _stormtrooperWidth / 2 + _stormtrooperWidth / 15, _startPosY + _stormtrooperHeight);
|
|
||||||
wingsPolygon.addPoint(_startPosX + _stormtrooperWidth / 2, _startPosY + _stormtrooperHeight);
|
|
||||||
|
|
||||||
g2d.setColor(bodyColor);
|
|
||||||
g.fillPolygon(wingsPolygon);
|
|
||||||
g2d.setColor(blackColor);
|
|
||||||
g.drawPolygon(wingsPolygon);
|
|
||||||
|
|
||||||
// Рисуем хвостовое оперение
|
|
||||||
Polygon tailPolygon = new Polygon();
|
|
||||||
tailPolygon.addPoint(_startPosX + _stormtrooperWidth, _startPosY + _stormtrooperHeight / 2 - _stormtrooperHeight / 3);
|
|
||||||
tailPolygon.addPoint(_startPosX + bodyWidth, _startPosY + _stormtrooperHeight / 2 - _stormtrooperHeight / 8);
|
|
||||||
tailPolygon.addPoint(_startPosX + bodyWidth, _startPosY + _stormtrooperHeight / 2 + _stormtrooperHeight / 8);
|
|
||||||
tailPolygon.addPoint(_startPosX + _stormtrooperWidth, _startPosY + _stormtrooperHeight / 2 + _stormtrooperHeight / 3);
|
|
||||||
|
|
||||||
g2d.setColor(bodyColor);
|
|
||||||
g.fillPolygon(tailPolygon);
|
|
||||||
g2d.setColor(blackColor);
|
|
||||||
g.drawPolygon(tailPolygon);
|
|
||||||
|
|
||||||
// Рисуем фюзеляж
|
|
||||||
g2d.setColor(bodyColor);
|
|
||||||
g2d.fillRect(
|
|
||||||
_startPosX + _stormtrooperWidth / 8,
|
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight / 2,
|
|
||||||
bodyWidth,
|
|
||||||
bodyHeight
|
|
||||||
);
|
|
||||||
g2d.setColor(blackColor);
|
|
||||||
g2d.drawRect(
|
|
||||||
_startPosX + _stormtrooperWidth / 8,
|
|
||||||
_startPosY + _stormtrooperHeight / 2 - bodyHeight / 2,
|
|
||||||
bodyWidth,
|
|
||||||
bodyHeight
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
ProjectStormtrooper/IMoveableObject.java
Normal file
8
ProjectStormtrooper/IMoveableObject.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package ProjectStormtrooper;
|
||||||
|
|
||||||
|
public interface IMoveableObject {
|
||||||
|
ObjectParameters GetObjectPosition();
|
||||||
|
int GetStep();
|
||||||
|
boolean CheckCanMove(EnumDirectionType direction);
|
||||||
|
void MoveObject(EnumDirectionType direction);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user