Before being able to run freeVikings with our new map, we must
create a text file which describes it.
This file is called "location file" and it's name is always
location.xml
.
It's a XML file with special
tags.
I assume you know at least the basics of XML (or HTML),
but even if you don't it shouldn't be a problem for you to get the
idea quickly and make the description files like an old XML guru.
The file has a following structure (If you don't know much about XML, you can copy it and use it as a skeleton of similar files in future):
<?xml version="1.0" ?> <location> <info> <title>DevGuide: CH1: First map: example 1</title> <author>Jakub Pavlik</author> </info> <body> <password>FRMP</password> <map src="firstmap_loc.tmx"/> <start horiz="70" vertic="60"/> <exit horiz="520" vertic="320"/> </body> </location>
The map description is divided into two blocks, info and body (inspired by HTML...). While the info block could be left out if you didn't want the map to have a name and to be signed as a product of yours, the second block, body, is the essential one. FreeVikings wouldn't be able to load the map without it. All tags in the body section are compulsory.
<password>FRMP</password>
Block tag password must contain a "word" made of four alphanumeric characters (e.g. FRMP, ZF23, ...). A small, maybe important, note: FreeVikings don't recognize upcase and downcase letters. It defines password of the level.
You should try to grep through all levels packed in the freeVikings distribution to be sure that you won't use a password which is already in use. Having grep on your computer, it is quick, simple and useful:
[igneus@vidhost freeVikings]$
grep FRMP ./locs/DefaultCampaign/*/*/location.xml
<map src="firstmap_loc.tmx"/>
This tag says where to search for the map data. Name of the map file is value of attribute src (I hope that all HTML-web-people are at home).
<start horiz="70" vertic="60"/> <exit horiz="520" vertic="320"/>
Both tags have the same structure. Values of attributes horiz and vertic[4] define two very important places on the map.
Start is the initial position of top-left corners of the vikings. How to get it? Remember that tiles are 40x40 px, vikings 80x100 px. I hope it isn't hard to understand the idea of the image above.
Exit works in a similar way, but it isn't position of vikings, but position of the EXIT point that all of them have to reach to pass to the next level.
How to get the right position of start and exit? Ask Tiled to show grid and coordinates: CtrlG) and then →
→ (I decided to start in the top left corner. Viking is 80px wide and 100px high. Surface of the first step is 5th row of tiles (y = 4*40 = 160px). Vikings' y-coordinate has to be "floor - viking_height", i.e. 160 - 100 = 60. x-coordinatecan be anything higher than 40 (because first column of tiles is a wall)
<start horiz="70" vertic="60"/>
Note that you don't have to place vikings directly on the floor as I've just done. You can as well place them somewhere in the free space so that they fall at the beginning of level.
Position of exit is computed in a similar way. Exit's size is 40x40px (same as size of tile).
<exit horiz="520" vertic="320"/>
[4] horiz means x and vertic y; in the past I wasn't able to remember which axis is x and which is y...