diff --git a/Direction.java b/Direction.java index cc121e9..e34e162 100644 --- a/Direction.java +++ b/Direction.java @@ -1,3 +1,3 @@ public enum Direction { - Up, Down, Left, Right + None,Up, Down, Left, Right } diff --git a/DrawningLocomotive.java b/DrawningLocomotive.java index e2cc62a..1e78705 100644 --- a/DrawningLocomotive.java +++ b/DrawningLocomotive.java @@ -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}; + } }