From 3c3fe9a53ff7a337fde4ae35864cbeb4bd923387 Mon Sep 17 00:00:00 2001 From: olshab Date: Tue, 28 Nov 2023 23:04:39 +0400 Subject: [PATCH] Need to fix downright --- src/AirBomber/Entities/BomberEntityBase.java | 2 ++ src/AirBomber/Rendering/BomberRenderer.java | 2 +- src/AirBomber/Rendering/BomberRendererBase.java | 13 ++++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/AirBomber/Entities/BomberEntityBase.java b/src/AirBomber/Entities/BomberEntityBase.java index 7a3d699..896c6b8 100644 --- a/src/AirBomber/Entities/BomberEntityBase.java +++ b/src/AirBomber/Entities/BomberEntityBase.java @@ -14,6 +14,8 @@ public class BomberEntityBase this.Speed = Speed; this.Weight = Weight; this.BodyColor = BodyColor; + + this.Step = (double)Speed * 100 / Weight * 5 / 2; } public int GetSpeed() { return Speed; } diff --git a/src/AirBomber/Rendering/BomberRenderer.java b/src/AirBomber/Rendering/BomberRenderer.java index d9a9fe1..101d4ce 100644 --- a/src/AirBomber/Rendering/BomberRenderer.java +++ b/src/AirBomber/Rendering/BomberRenderer.java @@ -9,7 +9,7 @@ public class BomberRenderer extends BomberRendererBase { super(Speed, Weight, BodyColor, Width, Height, 200, 200); - if (EntityBomber == null) + if (EntityBomber != null) EntityBomber = new BomberEntity(Speed, Weight, BodyColor, AdditionalColor, FuelTanks, Bombs); } diff --git a/src/AirBomber/Rendering/BomberRendererBase.java b/src/AirBomber/Rendering/BomberRendererBase.java index 04b2d57..aa18112 100644 --- a/src/AirBomber/Rendering/BomberRendererBase.java +++ b/src/AirBomber/Rendering/BomberRendererBase.java @@ -4,6 +4,7 @@ import AirBomber.*; import AirBomber.Entities.*; import AirBomber.MovementStrategy.*; import java.awt.*; +import java.util.Random; public class BomberRendererBase { @@ -35,6 +36,11 @@ public class BomberRendererBase _pictureHeight = Height; EntityBomber = new BomberEntityBase(Speed, Weight, BodyColor); + + EngineRenderer = new EngineRenderer(); + + Random Random = new Random(); + EngineRenderer.SetAmount(Random.nextInt(1, 7)); } public BomberRendererBase(int Speed, double Weight, Color BodyColor, int Width, int Height, int EntityWidth, int EntityHeight) @@ -49,6 +55,11 @@ public class BomberRendererBase _bomberHeight = EntityHeight; EntityBomber = new BomberEntityBase(Speed, Weight, BodyColor); + + EngineRenderer = new EngineRenderer(); + + Random Random = new Random(); + EngineRenderer.SetAmount(Random.nextInt(1, 7)); } public BomberEntityBase GetEntityBomber() { return EntityBomber; } @@ -98,7 +109,7 @@ public class BomberRendererBase public void MoveEntity(DirectionType Direction) { - if (EntityBomber == null) + if (EntityBomber == null || !CanMove(Direction)) return; switch (Direction)