Fixed Problems.
This commit is contained in:
parent
400672b6dd
commit
2920306b70
@ -3,7 +3,8 @@ import java.util.Random;
|
|||||||
|
|
||||||
class DrawningLocomotive {
|
class DrawningLocomotive {
|
||||||
public EntityLocomotive Locomotive;
|
public EntityLocomotive Locomotive;
|
||||||
public IDrawningExtra[] drawningExtra;
|
public ExtraWheelsDraw extraWheelsDraw;
|
||||||
|
public IDrawningExtra drawningExtra;
|
||||||
/// Левая координата отрисовки локомотива
|
/// Левая координата отрисовки локомотива
|
||||||
protected float _startPosX;
|
protected float _startPosX;
|
||||||
/// Верхняя координата отрисовки локомотива
|
/// Верхняя координата отрисовки локомотива
|
||||||
@ -20,10 +21,19 @@ class DrawningLocomotive {
|
|||||||
private final Random random = new Random();
|
private final Random random = new Random();
|
||||||
public DrawningLocomotive(int speed, float weight, Color bodyColor)
|
public DrawningLocomotive(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
int randExtra = random.nextInt(3);
|
int randExtra = random.nextInt(2);
|
||||||
drawningExtra = new IDrawningExtra[2];
|
extraWheelsDraw = new ExtraWheelsDraw(randExtra, bodyColor);
|
||||||
drawningExtra[0] = new ExtraWheelsDraw(randExtra, bodyColor);
|
switch (random.nextInt(3)){
|
||||||
drawningExtra[1] = random.nextBoolean() ? new ExtraRoundWheelDraw(randExtra) : new ExtraStarWheelDraw(randExtra);
|
case 0:
|
||||||
|
drawningExtra = new ExtraStarWheelDraw(randExtra);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
drawningExtra = new ExtraRoundWheelDraw(randExtra);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
drawningExtra = new ExtraWheelsDraw(randExtra, bodyColor);
|
||||||
|
break;
|
||||||
|
}
|
||||||
Locomotive = new EntityLocomotive(speed, weight, bodyColor);
|
Locomotive = new EntityLocomotive(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,9 +123,9 @@ class DrawningLocomotive {
|
|||||||
g.setColor(Color.BLACK);
|
g.setColor(Color.BLACK);
|
||||||
g.fillRect( (int)_startPosX + 50, (int)_startPosY + 10, 10, 20);
|
g.fillRect( (int)_startPosX + 50, (int)_startPosY + 10, 10, 20);
|
||||||
//колеса
|
//колеса
|
||||||
drawningExtra[0].DrawExtra((int)_startPosX, (int)_startPosY, g);
|
extraWheelsDraw.DrawExtra((int)_startPosX, (int)_startPosY, g);
|
||||||
//extra
|
//extra
|
||||||
drawningExtra[1].DrawExtra((int)_startPosX, (int)_startPosY, g);
|
drawningExtra.DrawExtra((int)_startPosX, (int)_startPosY, g);
|
||||||
//движок
|
//движок
|
||||||
g.setColor(Locomotive.getBodyColor());
|
g.setColor(Locomotive.getBodyColor());
|
||||||
g.fillRect((int)_startPosX + 100, (int)_startPosY + 10, 10, 30);
|
g.fillRect((int)_startPosX + 100, (int)_startPosY + 10, 10, 30);
|
||||||
|
@ -85,25 +85,25 @@ public class FormMap extends JComponent {
|
|||||||
statusPanel.add(weightLabel);
|
statusPanel.add(weightLabel);
|
||||||
statusPanel.add(colorLabel);
|
statusPanel.add(colorLabel);
|
||||||
|
|
||||||
JButton moveDownButton = new JButton("D");
|
JButton moveDownButton = new JButton("Down");
|
||||||
moveDownButton.addActionListener(e -> {
|
moveDownButton.addActionListener(e -> {
|
||||||
if(bufferImg != null) bufferImg = _abstractMap.MoveObject(Direction.Down);
|
if(bufferImg != null) bufferImg = _abstractMap.MoveObject(Direction.Down);
|
||||||
repaint();
|
repaint();
|
||||||
});
|
});
|
||||||
|
|
||||||
JButton moveUpButton = new JButton("U");
|
JButton moveUpButton = new JButton("Up");
|
||||||
moveUpButton.addActionListener(e -> {
|
moveUpButton.addActionListener(e -> {
|
||||||
if(bufferImg != null) bufferImg = _abstractMap.MoveObject(Direction.Up);
|
if(bufferImg != null) bufferImg = _abstractMap.MoveObject(Direction.Up);
|
||||||
repaint();
|
repaint();
|
||||||
});
|
});
|
||||||
|
|
||||||
JButton moveLeftButton = new JButton("L");
|
JButton moveLeftButton = new JButton("Left");
|
||||||
moveLeftButton.addActionListener(e -> {
|
moveLeftButton.addActionListener(e -> {
|
||||||
if(bufferImg != null) bufferImg = _abstractMap.MoveObject(Direction.Left);
|
if(bufferImg != null) bufferImg = _abstractMap.MoveObject(Direction.Left);
|
||||||
repaint();
|
repaint();
|
||||||
});
|
});
|
||||||
|
|
||||||
JButton moveRightButton = new JButton("R");
|
JButton moveRightButton = new JButton("Right");
|
||||||
moveRightButton.addActionListener(e -> {
|
moveRightButton.addActionListener(e -> {
|
||||||
if(bufferImg != null) bufferImg = _abstractMap.MoveObject(Direction.Right);
|
if(bufferImg != null) bufferImg = _abstractMap.MoveObject(Direction.Right);
|
||||||
repaint();
|
repaint();
|
||||||
|
Loading…
Reference in New Issue
Block a user