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