44 lines
1.2 KiB
Java
44 lines
1.2 KiB
Java
import java.awt.*;
|
|
|
|
public class LongMap extends AbstractMap{
|
|
@Override
|
|
protected void GenerateMap()
|
|
{
|
|
_map = new int[100][100];
|
|
_size_x = (float)_width / _map[0].length;
|
|
_size_y = (float)_height / _map[1].length;
|
|
int counter = 0;
|
|
for (int i = 0; i < _map[0].length; ++i)
|
|
{
|
|
for (int j = 0; j < _map[1].length; ++j)
|
|
{
|
|
_map[i][j] = _freeRoad;
|
|
}
|
|
}
|
|
while (counter < 5)
|
|
{
|
|
int xStart = _random.nextInt(0, 100);
|
|
int xEnd = _random.nextInt(80, 100);
|
|
|
|
for (int i = xStart; i <= xEnd; ++i)
|
|
{
|
|
_map[i] [xStart] = _barrier;
|
|
}
|
|
|
|
counter++;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void DrawBarrierPart(Graphics gr, int i, int j) {
|
|
gr.setColor(Color.GRAY);
|
|
gr.fillRect((int) (i * _size_x), (int) (j * _size_y), (int) (i * (_size_x + 1)), (int) (j * (_size_y + 1)));
|
|
}
|
|
|
|
@Override
|
|
protected void DrawRoadPart(Graphics gr, int i, int j) {
|
|
gr.setColor(Color.BLACK);
|
|
gr.fillRect((int) (i * _size_x), (int) (j * _size_y), (int) (i * (_size_x + 1)), (int) (j * (_size_y + 1)));
|
|
}
|
|
}
|