Добавлено доп. перечисление и отформатирован код
This commit is contained in:
parent
bf32d9a57d
commit
6382b11542
@ -1,7 +1,6 @@
|
||||
package ProjectStormtrooper;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
public class DrawingStormtrooper {
|
||||
public EntityStormtrooper EntityStormtrooper;
|
||||
@ -41,7 +40,7 @@ public class DrawingStormtrooper {
|
||||
_startPosY = y;
|
||||
}
|
||||
|
||||
public void MoveTransport(DirectionType direction) {
|
||||
public void MoveTransport(EnumDirectionType direction) {
|
||||
if (EntityStormtrooper == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -9,9 +9,11 @@ public class EntityStormtrooper {
|
||||
public Color AdditionalColor;
|
||||
public boolean Rockets;
|
||||
public boolean Bombs;
|
||||
|
||||
public double Step() {
|
||||
return (double) Speed * 250 / Weight;
|
||||
}
|
||||
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, boolean rockets, boolean bombs) {
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
|
@ -1,5 +1,5 @@
|
||||
package ProjectStormtrooper;
|
||||
|
||||
public enum DirectionType {
|
||||
public enum EnumDirectionType {
|
||||
Up, Down, Left, Right
|
||||
}
|
12
ProjectStormtrooper/EnumEnginesCount.java
Normal file
12
ProjectStormtrooper/EnumEnginesCount.java
Normal file
@ -0,0 +1,12 @@
|
||||
package ProjectStormtrooper;
|
||||
|
||||
public enum EnumEnginesCount {
|
||||
Two(2),
|
||||
Four(4),
|
||||
Six(6);
|
||||
public final int count;
|
||||
|
||||
EnumEnginesCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ package ProjectStormtrooper;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Random;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class FormStormtrooper {
|
||||
@ -14,9 +13,11 @@ public class FormStormtrooper {
|
||||
private JButton buttonUp;
|
||||
private JButton buttonLeft;
|
||||
private JButton buttonRight;
|
||||
|
||||
public JPanel getPictureBox() {
|
||||
return pictureBox;
|
||||
}
|
||||
|
||||
public FormStormtrooper() {
|
||||
buttonUp.setName("buttonUp");
|
||||
buttonDown.setName("buttonDown");
|
||||
@ -48,16 +49,16 @@ public class FormStormtrooper {
|
||||
|
||||
switch (buttonName) {
|
||||
case ("buttonUp") -> {
|
||||
_drawingStormtrooper.MoveTransport(DirectionType.Up);
|
||||
_drawingStormtrooper.MoveTransport(EnumDirectionType.Up);
|
||||
}
|
||||
case ("buttonDown") -> {
|
||||
_drawingStormtrooper.MoveTransport(DirectionType.Down);
|
||||
_drawingStormtrooper.MoveTransport(EnumDirectionType.Down);
|
||||
}
|
||||
case ("buttonLeft") -> {
|
||||
_drawingStormtrooper.MoveTransport(DirectionType.Left);
|
||||
_drawingStormtrooper.MoveTransport(EnumDirectionType.Left);
|
||||
}
|
||||
case ("buttonRight") -> {
|
||||
_drawingStormtrooper.MoveTransport(DirectionType.Right);
|
||||
_drawingStormtrooper.MoveTransport(EnumDirectionType.Right);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,6 +70,7 @@ public class FormStormtrooper {
|
||||
buttonLeft.addActionListener(buttonMoveClickedListener);
|
||||
buttonRight.addActionListener(buttonMoveClickedListener);
|
||||
}
|
||||
|
||||
public void Draw() {
|
||||
if (_drawingStormtrooper.EntityStormtrooper == null) {
|
||||
return;
|
||||
|
@ -4,6 +4,7 @@ import javax.swing.*;
|
||||
|
||||
public class MainFrameStormtrooper extends JFrame {
|
||||
private FormStormtrooper _formStormtrooper;
|
||||
|
||||
public MainFrameStormtrooper() {
|
||||
super();
|
||||
setTitle("Штурмовик");
|
||||
|
Loading…
Reference in New Issue
Block a user