Правки по оформлению.
This commit is contained in:
parent
5adccc16a3
commit
08ea99c93e
@ -10,7 +10,6 @@ public abstract class AbstractMap
|
|||||||
protected int _height;
|
protected int _height;
|
||||||
protected float _size_x;
|
protected float _size_x;
|
||||||
protected float _size_y;
|
protected float _size_y;
|
||||||
protected float[] position;
|
|
||||||
protected Random _random = new Random();
|
protected Random _random = new Random();
|
||||||
protected int _freeRoad = 0;
|
protected int _freeRoad = 0;
|
||||||
protected int _barrier = 1;
|
protected int _barrier = 1;
|
||||||
@ -119,29 +118,6 @@ public abstract class AbstractMap
|
|||||||
return DrawMapWithObject();
|
return DrawMapWithObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
private Direction MoveObjectBack(Direction direction)
|
|
||||||
{
|
|
||||||
switch (direction)
|
|
||||||
{
|
|
||||||
case Up:
|
|
||||||
return Direction.Up;
|
|
||||||
break;
|
|
||||||
case Down:
|
|
||||||
return Direction.Down;
|
|
||||||
break;
|
|
||||||
case Left:
|
|
||||||
return Direction.Left;
|
|
||||||
break;
|
|
||||||
case Right:
|
|
||||||
return Direction.Right;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Direction.None;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
private boolean SetObjectOnMap()
|
private boolean SetObjectOnMap()
|
||||||
{
|
{
|
||||||
if(_drawingObject == null || _map == null)
|
if(_drawingObject == null || _map == null)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class DesertStormMap extends AbstractMap{
|
public class DesertStormMap extends AbstractMap
|
||||||
|
{
|
||||||
//цвет закрытого участка
|
//цвет закрытого участка
|
||||||
private final Color barriedColor = new Color(139, 0, 0);
|
private final Color barriedColor = new Color(139, 0, 0);
|
||||||
|
|
||||||
@ -8,7 +9,8 @@ public class DesertStormMap extends AbstractMap{
|
|||||||
private final Color roadColor = new Color(255, 140, 0);
|
private final Color roadColor = new Color(255, 140, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void GenerateMap() {
|
protected void GenerateMap()
|
||||||
|
{
|
||||||
_map = new int[100][100];
|
_map = new int[100][100];
|
||||||
_size_x = (float)_width / _map.length;
|
_size_x = (float)_width / _map.length;
|
||||||
_size_y = (float)_height / _map[0].length;
|
_size_y = (float)_height / _map[0].length;
|
||||||
@ -36,14 +38,16 @@ public class DesertStormMap extends AbstractMap{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void DrawRoadPart(Graphics g, int i, int j) {
|
protected void DrawRoadPart(Graphics g, int i, int j)
|
||||||
|
{
|
||||||
Graphics2D g2d = (Graphics2D)g;
|
Graphics2D g2d = (Graphics2D)g;
|
||||||
g2d.setPaint(roadColor);
|
g2d.setPaint(roadColor);
|
||||||
g2d.fillRect((int)(i * _size_x), (int)(j * _size_y), (int)(i * (_size_x + 1)), (int)(j *(_size_y + 1)));
|
g2d.fillRect((int)(i * _size_x), (int)(j * _size_y), (int)(i * (_size_x + 1)), (int)(j *(_size_y + 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void DrawBarrierPart(Graphics g, int i, int j) {
|
protected void DrawBarrierPart(Graphics g, int i, int j)
|
||||||
|
{
|
||||||
Graphics2D g2d = (Graphics2D)g;
|
Graphics2D g2d = (Graphics2D)g;
|
||||||
g2d.setPaint(barriedColor);
|
g2d.setPaint(barriedColor);
|
||||||
g.fillRect((int)(i * _size_x), (int)(j * _size_y), (int)(i * (_size_x + 1)), (int)(j *(_size_y + 1)));
|
g.fillRect((int)(i * _size_x), (int)(j * _size_y), (int)(i * (_size_x + 1)), (int)(j *(_size_y + 1)));
|
||||||
|
@ -4,9 +4,7 @@ public class DrawningObjectPlane implements IDrawningObject
|
|||||||
{
|
{
|
||||||
private DrawingPlane _plane = null;
|
private DrawingPlane _plane = null;
|
||||||
|
|
||||||
public DrawningObjectPlane(DrawingPlane plane){
|
public DrawningObjectPlane(DrawingPlane plane){ _plane = plane; }
|
||||||
_plane = plane;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float Step()
|
public float Step()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class EntityAirbus extends EntityPlane{
|
public class EntityAirbus extends EntityPlane
|
||||||
|
{
|
||||||
//Дополнительный цвет
|
//Дополнительный цвет
|
||||||
public Color AddColor;
|
public Color AddColor;
|
||||||
|
|
||||||
|
@ -43,7 +43,9 @@ public class FormAirbus
|
|||||||
ButtonDown.setIcon(new ImageIcon(img));
|
ButtonDown.setIcon(new ImageIcon(img));
|
||||||
img = ImageIO.read(getClass().getResource("resourses/Right.png"));
|
img = ImageIO.read(getClass().getResource("resourses/Right.png"));
|
||||||
ButtonRight.setIcon(new ImageIcon(img));
|
ButtonRight.setIcon(new ImageIcon(img));
|
||||||
} catch (Exception ex){
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
System.out.println(ex.getMessage());
|
System.out.println(ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,8 @@ public class FormMap extends JFrame
|
|||||||
|
|
||||||
public void Draw()
|
public void Draw()
|
||||||
{
|
{
|
||||||
if (bufferImg == null) {
|
if (bufferImg == null)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +77,8 @@ public class FormMap extends JFrame
|
|||||||
ButtonDown.setIcon(new ImageIcon(img));
|
ButtonDown.setIcon(new ImageIcon(img));
|
||||||
img = ImageIO.read(getClass().getResource("resourses/Right.png"));
|
img = ImageIO.read(getClass().getResource("resourses/Right.png"));
|
||||||
ButtonRight.setIcon(new ImageIcon(img));
|
ButtonRight.setIcon(new ImageIcon(img));
|
||||||
} catch (Exception ex)
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
System.out.println(ex.getMessage());
|
System.out.println(ex.getMessage());
|
||||||
}
|
}
|
||||||
@ -176,7 +178,6 @@ public class FormMap extends JFrame
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
ComboBoxSelectorMap.addActionListener(new ActionListener() {
|
ComboBoxSelectorMap.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public interface IAdditionalDrawingObject {
|
public interface IAdditionalDrawingObject
|
||||||
|
{
|
||||||
void SetAddEnum(int airplaneWindow);
|
void SetAddEnum(int airplaneWindow);
|
||||||
void DrawAirplaneWindow(Color colorAirplaneWindow, Graphics g, float _startPosX, float _startPosY);
|
void DrawAirplaneWindow(Color colorAirplaneWindow, Graphics g, float _startPosX, float _startPosY);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public interface IDrawningObject {
|
public interface IDrawningObject
|
||||||
|
{
|
||||||
//шаг перемещения объекта
|
//шаг перемещения объекта
|
||||||
public float Step();
|
public float Step();
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public class Main {
|
public class Main
|
||||||
public static void main(String[] args) {
|
{
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
JFrame frame = new JFrame("Airbus");
|
JFrame frame = new JFrame("Airbus");
|
||||||
frame.setContentPane(new FormMap().MainPanel);
|
frame.setContentPane(new FormMap().MainPanel);
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class SimpleMap extends AbstractMap{
|
public class SimpleMap extends AbstractMap
|
||||||
|
{
|
||||||
//цвет закрытого участка
|
//цвет закрытого участка
|
||||||
private final Color barriedColor = Color.black;
|
private final Color barriedColor = Color.black;
|
||||||
|
|
||||||
@ -8,7 +9,8 @@ public class SimpleMap extends AbstractMap{
|
|||||||
private final Color roadColor = Color.gray;
|
private final Color roadColor = Color.gray;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void GenerateMap() {
|
protected void GenerateMap()
|
||||||
|
{
|
||||||
_map = new int[100][100];
|
_map = new int[100][100];
|
||||||
_size_x = (float)_width / _map.length;
|
_size_x = (float)_width / _map.length;
|
||||||
_size_y = (float)_height / _map[0].length;
|
_size_y = (float)_height / _map[0].length;
|
||||||
@ -36,14 +38,16 @@ public class SimpleMap extends AbstractMap{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void DrawRoadPart(Graphics g, int i, int j) {
|
protected void DrawRoadPart(Graphics g, int i, int j)
|
||||||
|
{
|
||||||
Graphics2D g2d = (Graphics2D)g;
|
Graphics2D g2d = (Graphics2D)g;
|
||||||
g2d.setPaint(roadColor);
|
g2d.setPaint(roadColor);
|
||||||
g2d.fillRect((int)(i * _size_x), (int)(j * _size_y), (int)(i * (_size_x + 1)), (int)(j *(_size_y + 1)));
|
g2d.fillRect((int)(i * _size_x), (int)(j * _size_y), (int)(i * (_size_x + 1)), (int)(j *(_size_y + 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void DrawBarrierPart(Graphics g, int i, int j) {
|
protected void DrawBarrierPart(Graphics g, int i, int j)
|
||||||
|
{
|
||||||
Graphics2D g2d = (Graphics2D)g;
|
Graphics2D g2d = (Graphics2D)g;
|
||||||
g2d.setPaint(barriedColor);
|
g2d.setPaint(barriedColor);
|
||||||
g2d.fillRect((int)(i * _size_x), (int)(j * _size_y), (int)(i * (_size_x + 1)), (int)(j *(_size_y + 1)));
|
g2d.fillRect((int)(i * _size_x), (int)(j * _size_y), (int)(i * (_size_x + 1)), (int)(j *(_size_y + 1)));
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class StarWarsMap extends AbstractMap{
|
public class StarWarsMap extends AbstractMap
|
||||||
|
{
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
|
|
||||||
//цвет закрытого участка
|
//цвет закрытого участка
|
||||||
@ -11,7 +12,8 @@ public class StarWarsMap extends AbstractMap{
|
|||||||
private final Color roadColor = new Color(0, 0, 139);
|
private final Color roadColor = new Color(0, 0, 139);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void GenerateMap() {
|
protected void GenerateMap()
|
||||||
|
{
|
||||||
_map = new int[100][100];
|
_map = new int[100][100];
|
||||||
_size_x = (float)_width / _map.length;
|
_size_x = (float)_width / _map.length;
|
||||||
_size_y = (float)_height / _map[0].length;
|
_size_y = (float)_height / _map[0].length;
|
||||||
@ -39,14 +41,16 @@ public class StarWarsMap extends AbstractMap{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void DrawRoadPart(Graphics g, int i, int j) {
|
protected void DrawRoadPart(Graphics g, int i, int j)
|
||||||
|
{
|
||||||
Graphics2D g2d = (Graphics2D)g;
|
Graphics2D g2d = (Graphics2D)g;
|
||||||
g2d.setPaint(roadColor);
|
g2d.setPaint(roadColor);
|
||||||
g2d.fillRect((int)(i * _size_x), (int)(j * _size_y), (int)(i * (_size_x + 1)), (int)(j *(_size_y + 1)));
|
g2d.fillRect((int)(i * _size_x), (int)(j * _size_y), (int)(i * (_size_x + 1)), (int)(j *(_size_y + 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void DrawBarrierPart(Graphics g, int i, int j) {
|
protected void DrawBarrierPart(Graphics g, int i, int j)
|
||||||
|
{
|
||||||
Graphics2D g2d = (Graphics2D)g;
|
Graphics2D g2d = (Graphics2D)g;
|
||||||
barriedColor = new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
|
barriedColor = new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
|
||||||
g2d.setPaint(barriedColor);
|
g2d.setPaint(barriedColor);
|
||||||
|
Loading…
Reference in New Issue
Block a user