Надеюсь что то получится
This commit is contained in:
parent
d79f7aab00
commit
523b5466b2
@ -2,7 +2,7 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/1 lab hard.iml" filepath="$PROJECT_DIR$/1 lab hard.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/ProjectGasolineTankerHard.iml" filepath="$PROJECT_DIR$/.idea/ProjectGasolineTankerHard.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -1,6 +1,8 @@
|
|||||||
public enum Direction {
|
public enum Direction {
|
||||||
Up,
|
Up(1),
|
||||||
Down,
|
Down(2),
|
||||||
Left,
|
Left(3),
|
||||||
Right;
|
Right(4),
|
||||||
|
None(0);
|
||||||
|
Direction(int value){}
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,7 @@ public class DrawingField extends JPanel {
|
|||||||
}
|
}
|
||||||
public void CreateButtonAction(){
|
public void CreateButtonAction(){
|
||||||
Random rnd=new Random();
|
Random rnd=new Random();
|
||||||
_gasolineTanker=new DrawingGasolineTanker();
|
_gasolineTanker=new DrawingGasolineTanker(rnd.nextInt(50)+10,rnd.nextInt(100)+500,new Color(rnd.nextInt(256),rnd.nextInt(256),rnd.nextInt(256)));
|
||||||
_gasolineTanker.Init(rnd.nextInt(50)+10,rnd.nextInt(100)+500,new Color(rnd.nextInt(256),rnd.nextInt(256),rnd.nextInt(256)));
|
|
||||||
_gasolineTanker.SetPosition(rnd.nextInt(100)+10,rnd.nextInt(100)+10,getWidth(),getHeight());
|
_gasolineTanker.SetPosition(rnd.nextInt(100)+10,rnd.nextInt(100)+10,getWidth(),getHeight());
|
||||||
field.SpeedLabel.setText("Speed: "+_gasolineTanker.getGasolineTanker().getSpeed());
|
field.SpeedLabel.setText("Speed: "+_gasolineTanker.getGasolineTanker().getSpeed());
|
||||||
field.WeightLabel.setText("Weight: "+_gasolineTanker.getGasolineTanker().getWeight());
|
field.WeightLabel.setText("Weight: "+_gasolineTanker.getGasolineTanker().getWeight());
|
||||||
|
@ -13,10 +13,9 @@ public class DrawingGasolineTanker {
|
|||||||
private final int _gasolineTankerWidth = 160;
|
private final int _gasolineTankerWidth = 160;
|
||||||
private final int _gasolineTankerHeight = 55;
|
private final int _gasolineTankerHeight = 55;
|
||||||
|
|
||||||
public void Init(int speed, float weight, Color bodyColor)
|
public DrawingGasolineTanker(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
GasolineTanker = new EntityGasolineTanker();
|
GasolineTanker = new EntityGasolineTanker(speed, weight, bodyColor);
|
||||||
GasolineTanker.Init(speed, weight, bodyColor);
|
|
||||||
Wheels = new DrawingWheels();
|
Wheels = new DrawingWheels();
|
||||||
Wheels.SetCountWheels((int)(2 + Math.random() + Math.random()*2));
|
Wheels.SetCountWheels((int)(2 + Math.random() + Math.random()*2));
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public class EntityGasolineTanker {
|
|||||||
}
|
}
|
||||||
public float Step;
|
public float Step;
|
||||||
|
|
||||||
public void Init(int speed, float weight, Color bodyColor){
|
public EntityGasolineTanker(int speed, float weight, Color bodyColor){
|
||||||
|
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
Speed = speed <= 0 ? rnd.nextInt(50)+10 : speed;
|
Speed = speed <= 0 ? rnd.nextInt(50)+10 : speed;
|
||||||
|
Loading…
Reference in New Issue
Block a user