diff options
-rw-r--r-- | tools/tmxcopy/map.cpp | 17 | ||||
-rw-r--r-- | tools/tmxcopy/readme.txt | 31 | ||||
-rw-r--r-- | tools/tmxcopy/tmx_random_fill.cpp | 2 | ||||
-rw-r--r-- | tools/tmxcopy/tmxcollide.cpp | 2 |
4 files changed, 41 insertions, 11 deletions
diff --git a/tools/tmxcopy/map.cpp b/tools/tmxcopy/map.cpp index 0fd764b4..75bd9a45 100644 --- a/tools/tmxcopy/map.cpp +++ b/tools/tmxcopy/map.cpp @@ -390,7 +390,17 @@ bool Map::randomFill(Map* templateMap, const std::string& destLayerName, } /* Now generate extra tiles. - * TODO Need to configure this for desired density. For 2x1 trees, dW*dH/10 is very sparse, dW*dH/2 is dense */ + * + * After considering ways to specify the number of objects to add, I think + * the best user interface (without integrating it with Tiled) is to place + * a small number of objects each time, and have the user run the utility + * several times, reloading the map in Tiled each time until it looks + * right. Simpler than typing magic numbers in at a command prompt. + * + * This algorithm completes after a fixed number of attempts at placing an + * object; regardless of how many attempts are successful. + * For 2x1 trees, destWidth*destHeight/10 is very sparse, dW*dH/2 is dense. + */ srand(time(NULL)); int patternsGenerated = 0; int occupiedAreas = 0; @@ -418,7 +428,6 @@ bool Map::randomFill(Map* templateMap, const std::string& destLayerName, if (areaIsClear) { int p = rand() % templateMap->getNumberOfLayers(); - std::cout <<"Copying pattern "<<p<<" to "<<x<<", "<<y<<std::endl; Layer* srcLayer = templateMap->getLayer(p); for (int loop_y=0; loop_y<templateMap->getHeight(); loop_y++) @@ -436,11 +445,11 @@ bool Map::randomFill(Map* templateMap, const std::string& destLayerName, else { occupiedAreas++; - std::cout <<"Area occupied "<<x<<", "<<y<<std::endl; } } std::clog<<"Generated " << patternsGenerated << " new objects" <<std::endl; + (void) occupiedAreas; // Unused at the moment, but keep it without a compiler warning about unused variables return true; } @@ -461,7 +470,7 @@ bool Map::translateAllLayers(Map* templateMap, const std::string& destLayerName, } if (!checkPassed) return false; - //FIXME - as is, this will add tilesets that are in the template but + //TODO This will unnecessarily add tilesets that are in the template but //not used in the main map std::map<int, int> tilesetTranslation = addAndTranslateTilesets(templateMap); diff --git a/tools/tmxcopy/readme.txt b/tools/tmxcopy/readme.txt index 972d1f66..52af1048 100644 --- a/tools/tmxcopy/readme.txt +++ b/tools/tmxcopy/readme.txt @@ -1,3 +1,10 @@ +=== TMX Map Tools === + +A set of tools for manipulating TMX map files. + +After using any of these tools, load the map in Tiled and save it again; until this is done the game may not be able to load the file (see Bugs for an explanation). + + === TMXCopy === Tmxcopy is a little tool that allows to copy parts of one TMX map to another map. This will make it much easier to match the border areas of maps. The program is command line based. The usage is: @@ -61,22 +68,36 @@ The template is a map where each layer is a pattern. For example, to make a woo It will then randomly place trees, but only in places where they won't overlap with other things on that layer. The size of the template map is the size of the area which must be empty in the destination layer. +Running it several times (without specifying an output file) will add more objects. After considering ways to specify the number of objects to add, I think the easiest is to just reload the map in Tiled each time until it looks right (you don't need to quit Tiled while running tmx_random_fill). -=== TMX Translate === -This tool is still to be written. I guarantee it will be written before I get a woodland map finished. +=== TMX Collide / Translate === A big woodland with lots of randomly-placed trees needs a complex collision layer, most of which can be generated from the visible layers. -This tool takes a two-layer template map - one layer contains visible tiles, and one layer contains collision tiles. +This tool does that automatic generation. + +It's not limited to adding collision tiles; it can be used for any task where tiles are added to one layer based on the tiles present in other layers. + +Usage: tmxcollide [-c] mapFile destLayer templateFile [-o outfile] + -c create layers, if they don't already exist in the target + -o save results to outfile, instead of overwriting the original + +To fill the collision layer, "destLayer" should be "Collision". + +As with TMX Random Fill, this tool takes a template map; for this tool it should have exactly two layers. + Upper layer: tiles to translate to (collision tiles) + Lower layer: tiles to translate from (visible tiles) +Blank tiles in the lower layer will be ignored (put a blank in the upper layer too). === Bugs (for all these programs) === -The program works so far but there are still some minor problems: +The programs work so far but there are still some minor problems: --Only tested for TMW-compilant maps. I don't guarantee that it works with Tiled maps that are made for other games and thus use different features. It is assumed that the target map and the source maps have the same number of layers, for example. +-Only tested for TMW-compilant maps. I don't guarantee that it works with Tiled maps that are made for other games and thus use different features. -Compressed maps (tmx.gz) can not be handled yet (but compressed or uncompressed layers work properly) -When the target map has an object layer it is moved to the bottom of the layer list of the map (no problem for the game but inconvenient for editing). Objects on the source map are ignored. +-All tilesets included in the srcFile (TMXCopy) or template (TMXRandomFill and TMXCollide) will be added to the output file, even if they aren't needed for the tiles that are added. -Layer data of output file isn't gzip-compressed yet -Created TMX file is a bit malformated (but working properly) diff --git a/tools/tmxcopy/tmx_random_fill.cpp b/tools/tmxcopy/tmx_random_fill.cpp index d55c9b58..2cc232fe 100644 --- a/tools/tmxcopy/tmx_random_fill.cpp +++ b/tools/tmxcopy/tmx_random_fill.cpp @@ -31,7 +31,7 @@ void printUsage() <<" -o save results to outfile, instead of overwriting the original"<<std::endl <<std::endl <<"Fill a rectangular area of mapFile's layer 'destLayer' with a random selection from the templateFile"<<std::endl - <<"TODO - more help here"<<std::endl; + <<"See readme.txt for full documentation"<<std::endl; } int main(int argc, char * argv[] ) diff --git a/tools/tmxcopy/tmxcollide.cpp b/tools/tmxcopy/tmxcollide.cpp index 2ce6f90b..a3600f61 100644 --- a/tools/tmxcopy/tmxcollide.cpp +++ b/tools/tmxcopy/tmxcollide.cpp @@ -31,7 +31,7 @@ void printUsage() <<" -o save results to outfile, instead of overwriting the original"<<std::endl <<std::endl <<"Using the template, translate visible layers to the collision layer"<<std::endl - <<"TODO - more help here"<<std::endl; + <<"See readme.txt for full documentation"<<std::endl; } int main(int argc, char * argv[] ) |