From 0f8658bfeb53d99cc96a9e4351b0f92775bdbd49 Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Sat, 24 Sep 2022 18:00:56 +0400 Subject: [PATCH] DrawTransport method added --- DrawningLocomotive.java | 28 ++++++++++++++++++++++++++-- EntityLocomotive.java | 6 ------ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/DrawningLocomotive.java b/DrawningLocomotive.java index cf537eb..19497c3 100644 --- a/DrawningLocomotive.java +++ b/DrawningLocomotive.java @@ -80,8 +80,32 @@ class DrawningLocomotive { } } - public void DrawTransport() { - //TODO: do! + public void DrawTransport(Graphics g) { + if (_startPosX < 0 || _startPosY < 0 + || _pictureHeight == null || _pictureWidth == null) + { + return; + } + //тело + g.setColor(Color.BLACK); + g.drawRect((int)_startPosX , (int)_startPosY, _locomotiveWidth - 10, _locomotiveHeight - 10); + //окна + g.setColor(Locomotive.getBodyColor()); + g.fillRect((int)_startPosX + 10, (int)_startPosY + 10, 10, 10); + g.fillRect((int)_startPosX + 30, (int)_startPosY + 10, 10, 10); + g.fillRect((int)_startPosX + 80, (int)_startPosY + 10, 10, 10); + //дверь + g.setColor(Color.BLACK); + g.drawRect( (int)_startPosX + 50, (int)_startPosY + 10, 10, 20); + //колеса + g.drawOval((int) _startPosX, (int)_startPosY + 40, 10, 10); + g.drawOval((int) _startPosX + 20, (int)_startPosY + 40, 10, 10); + g.drawOval((int) _startPosX + 70, (int)_startPosY + 40, 10, 10); + g.drawOval((int) _startPosX + 90, (int)_startPosY + 40, 10, 10); + //движок + g.setColor(Locomotive.getBodyColor()); + g.fillRect((int)_startPosX + 100, (int)_startPosY + 10, 10, 30); + } public void ChangeBorders(int width, int height) diff --git a/EntityLocomotive.java b/EntityLocomotive.java index 7d58451..440b8a1 100644 --- a/EntityLocomotive.java +++ b/EntityLocomotive.java @@ -37,10 +37,4 @@ public class EntityLocomotive { } BodyColor = bodyColor; } - - - - - - }