Added class DrawingObjectArtillery
This commit is contained in:
parent
f990882127
commit
6840f8220e
@ -25,7 +25,7 @@ public class DrawingArtillery {
|
||||
_artilleryHeight = artilleryHeight;
|
||||
}
|
||||
|
||||
public void SetPosition(int x, int y, int width, int height) {
|
||||
public void setPosition(int x, int y, int width, int height) {
|
||||
if (x < 0 || x + _artilleryWidth >= width)
|
||||
{
|
||||
return;
|
||||
|
37
DrawingObjectArtillery.java
Normal file
37
DrawingObjectArtillery.java
Normal file
@ -0,0 +1,37 @@
|
||||
import java.awt.*;
|
||||
|
||||
public class DrawingObjectArtillery implements IDrawingObject {
|
||||
private DrawingArtillery _artillery = null;
|
||||
|
||||
public DrawingObjectArtillery(DrawingArtillery artillery) {
|
||||
_artillery = artillery;
|
||||
}
|
||||
|
||||
public float getStep() {
|
||||
if (_artillery != null && _artillery.artillery != null) {
|
||||
return _artillery.artillery.getStep();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float[] getCurrentPosition() {
|
||||
if (_artillery != null) {
|
||||
return _artillery.getCurrentPosition();
|
||||
}
|
||||
return new float[] { 0, 0, 0, 0 };
|
||||
}
|
||||
|
||||
public void moveObject(Direction direction) {
|
||||
if (_artillery != null) {
|
||||
_artillery.moveTransport(direction);
|
||||
}
|
||||
}
|
||||
|
||||
public void setObject(int x, int y, int width, int height) {
|
||||
_artillery.setPosition(x, y, width, height);
|
||||
}
|
||||
|
||||
public void drawingObject(Graphics2D g) {
|
||||
_artillery.drawTransport(g);
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ public class FormArtillery extends JFrame {
|
||||
rnd.nextInt(0, 256)),
|
||||
rnd.nextInt(4, 7)
|
||||
);
|
||||
_artillery.SetPosition(10 + rnd.nextInt(90), 10 + rnd.nextInt(90), pictureBox.getWidth(), pictureBox.getHeight());
|
||||
_artillery.setPosition(10 + rnd.nextInt(90), 10 + rnd.nextInt(90), pictureBox.getWidth(), pictureBox.getHeight());
|
||||
speedLabel.setText(String.format("Скорость: %s", _artillery.getArtillery().getSpeed()));
|
||||
weightLabel.setText(String.format("Вес: %s", _artillery.getArtillery().getWeight()));
|
||||
colorLabel.setText(String.format("Цвет: %x", _artillery.getArtillery().getBodyColor().getRGB()));
|
||||
|
Loading…
Reference in New Issue
Block a user