Added and Fixed DrawningLocomotive & Direction
This commit is contained in:
parent
e9053085ef
commit
c68da6d45b
@ -1,3 +1,3 @@
|
||||
public enum Direction {
|
||||
Up, Down, Left, Right
|
||||
None,Up, Down, Left, Right
|
||||
}
|
||||
|
@ -5,17 +5,17 @@ class DrawningLocomotive {
|
||||
public EntityLocomotive Locomotive;
|
||||
public ExtraWheelsDraw extraWheelsDraw;
|
||||
/// Левая координата отрисовки локомотива
|
||||
private float _startPosX;
|
||||
protected float _startPosX;
|
||||
/// Верхняя координата отрисовки локомотива
|
||||
private float _startPosY;
|
||||
protected float _startPosY;
|
||||
/// Ширина окна отрисовки
|
||||
private Integer _pictureWidth = null;
|
||||
/// Высота окна отрисовки
|
||||
private Integer _pictureHeight = null;
|
||||
/// Ширина отрисовки локомотива
|
||||
private final int _locomotiveWidth = 120;
|
||||
private int _locomotiveWidth = 110;
|
||||
/// Высота отрисовки локомотива
|
||||
private final int _locomotiveHeight = 50;
|
||||
private int _locomotiveHeight = 50;
|
||||
/// Инициализация свойств
|
||||
private final Random random = new Random();
|
||||
public DrawningLocomotive(int speed, float weight, Color bodyColor)
|
||||
@ -23,6 +23,15 @@ class DrawningLocomotive {
|
||||
extraWheelsDraw = new ExtraWheelsDraw(random.nextInt(3), bodyColor);
|
||||
Locomotive = new EntityLocomotive(speed, weight, bodyColor);
|
||||
}
|
||||
|
||||
// Новый конструктор
|
||||
protected DrawningLocomotive (int speed, float weight, Color bodyColor, int locomotiveWidth, int locomotiveHeight)
|
||||
{
|
||||
this(speed, weight, bodyColor);
|
||||
_locomotiveWidth = locomotiveWidth;
|
||||
_locomotiveHeight = locomotiveHeight;
|
||||
}
|
||||
|
||||
/// Установка позиции локомотива
|
||||
public void SetPosition(int x, int y, int width, int height)
|
||||
{
|
||||
@ -126,4 +135,10 @@ class DrawningLocomotive {
|
||||
_startPosY = _pictureHeight - _locomotiveHeight;
|
||||
}
|
||||
}
|
||||
|
||||
// Получение текущей позиции объекта
|
||||
public float[] GetCurrentPosition()
|
||||
{
|
||||
return new float[] {/*UP*/_startPosY, /*RIGHT*/ _startPosX + _locomotiveWidth, /*DOWN*/ _startPosY + _locomotiveHeight, /*LEFT*/ _startPosX};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user