From 489964eb09f76fd0516c720b2156db6494be1b38 Mon Sep 17 00:00:00 2001 From: Hells Hound Date: Sat, 15 Oct 2022 21:46:05 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- src/DrawingWarship.java | 5 ++--- src/EntityWarship.java | 6 +++--- src/FormWarship.java | 3 +-- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 018dc79..344243f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/DrawingWarship.java b/src/DrawingWarship.java index 04c5463..f7aacff 100644 --- a/src/DrawingWarship.java +++ b/src/DrawingWarship.java @@ -14,10 +14,9 @@ public class DrawingWarship { private final int _warshipWidth = 114; private final int _warshipHeight = 40; - public void Init(int speed, float weight, Color bodyColor) + public DrawingWarship(int speed, float weight, Color bodyColor) { - Warship = new EntityWarship(); - Warship.Init(speed, weight, bodyColor); + Warship = new EntityWarship(speed, weight, bodyColor); Blocks = new DrawingBlocks(); Blocks.blockDirection = BlockRandom(); } diff --git a/src/EntityWarship.java b/src/EntityWarship.java index 092a65b..fd0d84d 100644 --- a/src/EntityWarship.java +++ b/src/EntityWarship.java @@ -11,11 +11,11 @@ public class EntityWarship { public Color GetBodyColor (){return BodyColor;} public float Step; - public void Init(int speed, float weight, Color bodyColor) + public EntityWarship(int speed, float weight, Color bodyColor) { Random rnd = new Random(); - Speed = speed <= 0 ? rnd.nextInt(100) + 50 : speed; - Weight = weight <= 0 ? rnd.nextInt(30)+40 : weight; + Speed = speed <= 0 ? rnd.nextInt(50, 150) : speed; + Weight = weight <= 0 ? rnd.nextInt(40, 70) : weight; BodyColor= bodyColor; Step = Speed * 100 / Weight; } diff --git a/src/FormWarship.java b/src/FormWarship.java index 404303a..020ae3a 100644 --- a/src/FormWarship.java +++ b/src/FormWarship.java @@ -50,8 +50,7 @@ public class FormWarship extends JFrame { @Override public void actionPerformed(ActionEvent e) { Random rnd = new Random(); - _warship = new DrawingWarship(); - _warship.Init(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000, + _warship = new DrawingWarship(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000, new Color(rnd.nextInt(256),rnd.nextInt(256),rnd.nextInt(256))); _warship.SetPosition(rnd.nextInt(90) + 10, rnd.nextInt(90) + 10, drawPanel.getWidth(), drawPanel.getHeight()); toolBarLabelSpeed.setText("Color: " + _warship.GetWarship().GetSpeed() + " ");