-
Notifications
You must be signed in to change notification settings - Fork 0
Home
API that gives you full controll over Dune 2000 maps. You can create map files, edit every map tile, use special algorithms that automatically place map structures and fill it up, knowing different tileset blocks and their relations - JSON tileset config file is used for it, config can be modified for any custom tileset.
Library has a simple classes and functions to work with it. Let's say, we want to fill any place with some type of plain. For that, we should open JSON tileset config, open a map we want to make changes, and with Palette class flood fill some places on the map:
TilesetProperties tileset_properties = load("data/tileset.json");
MapBinFileIO map_bin_file;
map_bin_file.open("temp.map");
Map map = map_bin_file.load();
Painter painter(&map, &tilesetProperties.palette);
painter.fill(40, 23, "sand", true);
painter.fill(0, 0, "rock", true);
painter.fill(40, 0, "rock", true);
map_bin_file.save(map);
map_bin_file.close();
As you can see, we load tileset.json. This file contains information about materials, blocks and other data. In the code, we used "sand" and "rock" as fill material. So, the library find them in the JSON file:
...
"palette": {
"rock":{
"x": 12,
"y": 27,
"width": 5,
"height": 3,
"compatibility": "rock_plain"
},
"sand":{
"x": 8,
"y": 2,
"width": 5,
"height": 2,
"compatibility": "sand"
},
"dunes":{
"x": 3,
"y": 3,
"width": 2,
"height": 3,
"compatibility": "dunes"
}
}, ...
So, it contains special coords, width and height for tileset. It determines, for example, where to locate all "rock" filler tiles:
In the code snippet we created a Painter - object that works with Palette (Map of all materials) and with the game Map for high level editing Map's content. Materials of palette are used for random picking one of the same type tiles, such as "rock" material showed above.
Then, we just save the edited map back to the file to see all the changes.
Before:
After:
To see all the possibilities of the library, look for other pages in the sidebar.