diff --git a/src/main/java/SimpleMap.java b/src/main/java/SimpleMap.java new file mode 100644 index 0000000..984b144 --- /dev/null +++ b/src/main/java/SimpleMap.java @@ -0,0 +1,42 @@ +import java.awt.*; + +public class SimpleMap extends AbstractMap{ + private final Color barrierColor = Color.BLACK; + private final Color roadColor = Color.GRAY; + @Override + protected void GenerateMap() { + map = new int[100][100]; + 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[0].length; ++j) + { + map[i][j] = _freeRoad; + } + } + while (counter < 50) + { + int x = random.nextInt(100); + int y = random.nextInt(100); + if (map[x][y] == _freeRoad) + { + map[x][y] = _barrier; + counter++; + } + } + } + + @Override + protected void DrawRoadPart(Graphics2D g, int i, int j) { + g.setColor(roadColor); + g.fillRect(i * (int)size_x, j * (int)size_y, (int)size_x, (int)size_y); + } + + @Override + protected void DrawBarrierPart(Graphics2D g, int i, int j) { + g.setColor(barrierColor); + g.fillRect(i * (int)size_x, j * (int)size_y, (int)size_x, (int)size_y); + } +}