Making Maps with tilesets and patches

User avatar
razorback
Posts: 26
Joined: Wed Jan 11, 2012 10:31 pm

Making Maps with tilesets and patches

Postby razorback » Mon Mar 03, 2014 1:33 pm

Hi, in this tutorial i will show you how to make maps with different tile sizes, for example make maps with 48x48 based tileset and then transform each one of them in four 24x24. Each one of those 24x24 has its own flags, like land,water,coast,no-building,etc. the big thing with this is that you can virtually make the map with any tile size and then divide the original tile in multiple sub-tiles, allowing the configuration of every sub-tile separately.

to start with this you need to have installed Tiled and Matlab, and have basic knowledge about how to use them both.
you will need these 3 files as well:
http://www.mediafire.com/view/7fe9hujy1710ebc/flag.png
http://www.mediafire.com/view/3avpr5bav ... odeTiles.m
http://www.mediafire.com/view/3ky30p7r8 ... atagizer.m
*both .m scripts must be in your matlab/bin folder

for explain this, step by step, in this tutorial i will make a map with a 96x96 based tileset in Tiled, configure the tileset script, export to stratagus, and load it in the editor to add units.

now let's get started:
1) first, you need to actually have a tileset graphic with the tile size you will use, i will use this:
http://www.mediafire.com/view/d5tr53yr3ivsr5t/swamp.png
you can realize that every tile has 96x96 pixels, also, you can realized that besides from the mixed and solid tiles, there are special tiles.
2) now, open Tiled, make a new map, set the map size and the tile size, i will make a 10x10 tiles with 96x96 tilesize.
3) go to Map->New Tileset->search the file and set the tile width and height with your previous measures
4) check the tileset windows for a button called "Edit Terrain information".
5) once there, you must make the different terrains and configurate them, for example i will make only three:
http://www.mediafire.com/view/c8u7i293e ... aininf.png
6) time to make the map!
http://www.mediafire.com/view/ukchicc8z ... _ready.png
7) once you are ready, save the .tmx (in the case you would like to change something) and export the map in .lua format
8) open the .lua file and open Matlab.
9) go to the bottom of the .lua file and search for a matrix of numbers, copy from the first number to the last (ONLY copy that, no more and no least).
10) back to Matlab and do this:
M = [*paste] (the parenthesis are very important).
11) now write:
Map = Stratagizer(M,Width,dim)
//Width: number of columns in big size, in my case Width = 6
//dim: number of tiles by row of each big tile
//for me ONE 96x96 means FOUR 24x24; dim = 4
12) you can see how the matlab command windows display the map in stratagus format, search in the matlab directory->Bin for a file called Map.doc, there you have your map, remember to adjust the map size in the stratagus .smp file.

at this point the map is ready, but surely you haven't configured the tileset script to support it, so it wont work.
13) open tiled again and create a new map, with the same tileset graphic but with the difference that now you must set the tilesize to the game dimensions and set the map size to a very special numbers (in my case i said that i would use sixteen 24x24 tiles from one 96x96, so my tilesizes are 24x24 now and the width will be "Width"*"dim" (the two previous values, in my case 6*4) and the Height will be a value big enough to completely copy the tileset graphic as a map, like this:
http://www.mediafire.com/view/5nw6t2fnp ... ttiled.png
14) add a new tileset graphic to the same map with the graphic "flag.png" (the one adjunted with this tutorial).
15) add a new layer to the map and call it "flags".
16) now you must configure every tile with a flag
Blue -> water
Green -> land
Orange -> Coast
Yellow -> land, "no-building"
Red -> "unpassable"
like this:
http://www.mediafire.com/view/x04cg5pkopo46ps/flags.png
17) once you have configured your map, save the .tmx file and export the file in .lua format
18) open the .lua and copy the matrix of numbers from the "flag" layer.
19) identify in that matrix the lowest number besides from zero (in my case 4321)
20) go to matlab and write:
M = [*paste]
Tileset = CodeTiles(M,adjust,name,location,game)
//adjust: the previous number 4321-1 = 4320 in the example
//name: the name of the tileset, 'swamp' (it's impotant the apostrophes)
//location: the location of the tileset in the stratagus folder 'tilesets/swamp/giantswamp.png'
//game: the name's game, in my case game = 'windgus'
Tileset = CodeTiles(M,4320,'swamp','tilesets/swamp/giantswamp.png','windgus')
21) search in the matlab folder->Bin for a file called Tileset.doc, copy all and paste in your tileset.lua (swamp.lua in my case)
22) now open stratagus->editor and load your map ;)
http://www.mediafire.com/view/l5zp450avfmq0sv/test.png
if you have follow all the steps, everything should be ok. From point 13 to 21 you need only to do one time, and if you learn well about how to use tiled, doing maps will be a very simply task.
User avatar
b_o
Posts: 328
Joined: Sun Jan 01, 2012 12:07 pm

Re: Making Maps with tilesets and patches

Postby b_o » Tue Mar 04, 2014 3:07 am

Thanks, are there any free versions of matlab?

Who is online

Users browsing this forum: No registered users and 3 guests