rework construction
This commit is contained in:
parent
60e488021c
commit
1c30871417
@ -16,10 +16,9 @@ public class DrawingShip extends JPanel {
|
||||
private DrawDeck dd = new DrawDeck();
|
||||
|
||||
//Инициализация
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public DrawingShip(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
warmlyShip = new EntityWarmlyShip();
|
||||
warmlyShip.Init(speed, weight, bodyColor);
|
||||
warmlyShip = new EntityWarmlyShip(speed, weight, bodyColor);
|
||||
Random random = new Random();
|
||||
dd.SetDeckCount(random.nextInt(1, 4));
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ public class EntityWarmlyShip {
|
||||
private float Step; //Шаг при перемещении
|
||||
|
||||
//Инициализация
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public EntityWarmlyShip(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random random = new Random();
|
||||
Speed = speed <= 0 ? random.nextInt(50, 150) : speed;
|
||||
|
@ -83,8 +83,7 @@ public class FormShip extends JFrame{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Random random = new Random();
|
||||
ship = new DrawingShip();
|
||||
ship.Init(random.nextInt(100, 300), random.nextInt(1000, 2000), new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)));
|
||||
ship = new DrawingShip(random.nextInt(100, 300), random.nextInt(1000, 2000), new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)));
|
||||
ship.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100), GraphicsOutput.getWidth(), GraphicsOutput.getHeight());
|
||||
JLabelSpeed.setText("Cкорость: " + ship.GetWarmlyShip().GetSpeed() + " ");
|
||||
JLabelWeight.setText("Вес: " + ship.GetWarmlyShip().GetWeight() + " ");
|
||||
|
Loading…
Reference in New Issue
Block a user