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