-
Notifications
You must be signed in to change notification settings - Fork 0
Procedural Map Generation
To keep gameplay unique and enhance replay value, the game map will be dynamically generated each playthrough. This means that players will have to adapt their strategy for building their militia and working force, as resources and enemies will not appear statically from game to game. In order to assist with this, the MapGenerator class has been developed, which features functionality to create and output a randomly generated map
It is necessary to include the class in all implementations
import com.deco2800.game.areas.MapGenerator.MapGenerator;
Generating a map should be done in a TerrainFactory class - for example - an implementation in the default TerrainFactory class, within the fillTiles() function:
//Generate a map with the following specifications
MapGenerator mg = new MapGenerator(mapWidth, mapHeight, citySize, islandSize);
//Store the map
char[][] map = mg.getMap();
for (int x = 0; x < mapWidth; x++) {
for (int y = 0; y < mapHeight; y++) {
Cell cell = new Cell();
if (map[y][x] == mg.getOceanChar()) {
//Set ocean tiles to ocean textures
cell.setTile(oceanTile);
} else {
//Set non-ocean tiles to sand textures
cell.setTile(sandTile);
}
//Add the cell to the map
layer.setCell(x, mapHeight - y, cell);
}
}
In this usage case, variables mapWidth, mapHeight, citySize, islandSize were all defined as static constants beforehand, and textures oceanTile and sandTile were also pre-defined TextureRegions.
Note that when setting the created cell to the layer, the y component is mapped inversely, as the MapGenerator's y component is defined inversely to the layer's.
//Create a new MapGenerator
MapGenerator mg = new MapGenerator(mapWidth, mapHeight, citySize, islandSize);
//Write the map to an output location - replace path as necessary
mg.writeMap("C:\\dir1\\dir2\\map.txt");
Which will give an output of the following form, with ocean tiles indicated '*', island tiles indicated 'I', and city tiles indicated 'c'
Map
City
Buildings
Unit Selections
Game User Testing: Theme of Unit Selection & Spell System
Health Bars
In Game menu
- Feature
- User Testing:In Game Menu
Landscape Tile Design Feedback