47 lines
1.1 KiB
Java
Raw Permalink Normal View History

2022-11-08 13:49:17 +04:00
package Classes.Maps;
import java.awt.*;
public class SimpleMap extends AbstractMap
{
@Override
protected void GenerateMap()
{
_map = new int[100][100];
_size_x = (float)_width / _map[0].length;
_size_y = (float)_height / _map.length;
int counter = 0;
for (int i = 0; i < _map.length; i++)
{
for (int j = 0; j < _map[i].length; j++)
{
if (_random.nextInt(0, 90) == 5)
{
_map[i][j] = _barrier;
}
else
{
_map[i][j] = _freeRoad;
}
}
}
}
@Override
protected void DrawRoadPart(Graphics g, int i, int j)
{
g.setColor(Color.GRAY);
g.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)
{
g.setColor(Color.BLACK);
g.fillRect((int) (i * _size_x), (int) (j * _size_y), (int) (i * (_size_x + 1)), (int) (j * (_size_y + 1)));
}
}