Added and Fixed DrawningLocomotive & Direction
This commit is contained in:
parent
e9053085ef
commit
c68da6d45b
@ -1,3 +1,3 @@
|
|||||||
public enum Direction {
|
public enum Direction {
|
||||||
Up, Down, Left, Right
|
None,Up, Down, Left, Right
|
||||||
}
|
}
|
||||||
|
@ -5,17 +5,17 @@ class DrawningLocomotive {
|
|||||||
public EntityLocomotive Locomotive;
|
public EntityLocomotive Locomotive;
|
||||||
public ExtraWheelsDraw extraWheelsDraw;
|
public ExtraWheelsDraw extraWheelsDraw;
|
||||||
/// Левая координата отрисовки локомотива
|
/// Левая координата отрисовки локомотива
|
||||||
private float _startPosX;
|
protected float _startPosX;
|
||||||
/// Верхняя координата отрисовки локомотива
|
/// Верхняя координата отрисовки локомотива
|
||||||
private float _startPosY;
|
protected float _startPosY;
|
||||||
/// Ширина окна отрисовки
|
/// Ширина окна отрисовки
|
||||||
private Integer _pictureWidth = null;
|
private Integer _pictureWidth = null;
|
||||||
/// Высота окна отрисовки
|
/// Высота окна отрисовки
|
||||||
private Integer _pictureHeight = 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();
|
private final Random random = new Random();
|
||||||
public DrawningLocomotive(int speed, float weight, Color bodyColor)
|
public DrawningLocomotive(int speed, float weight, Color bodyColor)
|
||||||
@ -23,6 +23,15 @@ class DrawningLocomotive {
|
|||||||
extraWheelsDraw = new ExtraWheelsDraw(random.nextInt(3), bodyColor);
|
extraWheelsDraw = new ExtraWheelsDraw(random.nextInt(3), bodyColor);
|
||||||
Locomotive = new EntityLocomotive(speed, weight, 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)
|
public void SetPosition(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
@ -126,4 +135,10 @@ class DrawningLocomotive {
|
|||||||
_startPosY = _pictureHeight - _locomotiveHeight;
|
_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