38 lines
1.2 KiB
Java
38 lines
1.2 KiB
Java
|
import java.awt.*;
|
||
|
|
||
|
public class LongMap extends AbstractMap{
|
||
|
|
||
|
@Override
|
||
|
protected void GenerateMap() {
|
||
|
_map = new int[60][60];
|
||
|
_size_x = (float) (_width / _map.length);
|
||
|
_size_y = (float) (_height / _map[0].length);
|
||
|
int counter = 0;
|
||
|
for (int i = 0; i < _map.length; ++i) {
|
||
|
for (int j = 0; j < _map[i].length; ++j) {
|
||
|
_map[i][j] = _freeWaterArea;
|
||
|
}
|
||
|
}
|
||
|
while (counter < 20) {
|
||
|
int x = _random.nextInt(59);
|
||
|
int y = _random.nextInt(59);
|
||
|
if (_map[x][y] == _freeWaterArea) {
|
||
|
_map[x][y] = _land;
|
||
|
counter++;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void DrawWaterPart(Graphics gr, int i, int j) {
|
||
|
gr.setColor(new Color(0xFFFFFF));
|
||
|
gr.fillRect((int) (i * _size_x), (int) (j * _size_y), (int) (i * (_size_x + 1)), (int) (j * (_size_y + 1)));
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void DrawLandPart(Graphics gr, int i, int j) {
|
||
|
gr.setColor(new Color(0x050303));
|
||
|
gr.fillRect((int) (i * _size_x), (int) (j * _size_y), (int) (i * (_size_x + 1)), (int) (j * (_size_y + 1)));
|
||
|
}
|
||
|
}
|