General Editor Familiarisation
-------------------------------
1. load the exe and load the map
2. main window on left can be zoomed by using MapTools menu
3. Tiles are to the right
4. Right click on the tiles to toggle to the animated tiles and again to toggle back
5. To fill an area with a tile (it fills all tiles matching and touching the tile at the location you are at) hover the mouse over a location on the map and press F
6. Can use CTRL-Z to undo

Tiles in the editor
-------------------
The title of the right-hand window shows the tile number you are on, and the title of the map window shows the position you are at and the tile number

The following tiles are not used in the game:
- 2 (brown square)
- all the ones with 'free' in the tile
- 57 (more on that one later) - the red blob
- the tiles that look the same as tile 1 from 163 onwards

Tile Overview
-------------
- The tiles that look like objects (trees, mountains, etc) are all collision objects - they stop you and the enemy
- the grass and dark muddy ones slow down the car slightly
- The light blue sea type squares (11, etc) slow the car down but can be driven over
- the dark blue tiles (3 onwards) is the sea and bounces the player like other objects

Map
---
- The map edges are not detected in code (to save coding edge of map checks every logic step)
- to avoid this you need a padding of 15 tiles at each end, look at template_survival.fmp and you'll see this as it's the smallest map file
- To achieve padding place a tile you cannot cross. All the maps currently designed use the blue sea
- To place a tile, simply select the block then click in the map. Use 'F' to fill

Animation
---------
- To place animation items, simply right-click the block window and place the tile you want as you would the normal tile. There are multiple ones the same because they have different speeds to make them look different.
- To see the animation, simply double click on the tile. If you do this on the normal objects, it brings up a similar screen, but don't change these values as you'll break it's use in the map

Layers
------
- Each map has multiple layers. The first layer is always the map you see on screen. The other layers are used for specific purposes within each game type.
- Layer 1 is used by the game to auto-place hint tiles. Basically because the enemy cars go so fast, the A* path-finder that they use tend to make them crash as the don't take into account the car speed. So when the map is loaded it goes through every collision tile and places tiles (tile 57 - the red blob) touching this tile, but on layer 1. It can then adjust for them better and stop enemies crashing so much.
- From the layer menu, select the 'layer x' option to view that layer
- if you want to see more than one layer (i.e. to overlay - which will become apparent next), select the main layer (layer 0 from the layer menu), select 'onion skin' and tick box with layer 0 from the layer menu, and select 'background layer darkened' (optional, but better I think) from the Layer menu. Now, if you select another layer you'll see that layer brightened and layer 0 dull in the background. This is probably better to see if you load the template_race file and select layer 2.

Map Design
----------
1. Use the template as a hint as to what to do.
1a. To resize the map to your size, press CTRL-R or use the MapTools menu and change the width/heighe.
1b. To clear the map for a blank one, select the layer then select to clear it from the Layer menu. It's probably best after clearing it to fill it will tile 3 (the basic blue sea)
2. Ensure the edges have at least 15 tiles padding
3. Ensure the car can't go past. All the samples use the animated sea - if you select any of the animated tiles from the main object window (i.e. the sea ones or the oil pump) they are static and won't animate - which is fine if that is what you want.
4. Layer 0 is the main game display, place your tiles as you would like to see them
5. Layer 1 is the auto block as described above for helping the A* path finding code.
6. However, note that for all maps you can pre-place tile 57 in layer 1. You do this to ensure the enemy car will avoid this tile. This is because it doesn't fully enclose a tile when it auto populates layer 1 (as it might end up creating a blocked path), it puts a random amount of tiles around it. I do this in the main game around mountains and on the race/survival maps because the tiles are generally well spaced out and so can have tile 57 all around it. Race especially because you can have the enemy car go at any speed.
- To view your map inside the editor, from the MapTools menu select Preview setup and select a decent screenmode, e.g. 800x600 or 640x480 (to match the game) at 32bpp and 60hz. Then select preview from the MapTools menu
- All sea, grass, mud, river, sea have tiles to fully surround them to make them look nice.

Survival Maps
-------------
- These should be small because the enemies need to find you - a few screens at most is a good number
- Only layer 0 is used, however, as with all maps you can place tile 57 on layer 1 if you wish.
- the current survival maps are all about 100x100 (minus 15 for padding)

Race
----
- This is probably the one you'll want to make. It's a race from the start to the finish.
- The current race maps are all about 200 tiles across/up the racing path
- Use layer 0 and layer 1 as Survival Map
- Layer 2 is for the start/end position. 
- Layer 3 is the way-points
- To set a start position for the player, select layer 1 and set tile 1 down where you want to start from, tile two for the enemy car if you are having one. The template file has about 10, but that's for the networked version which isn't done yet - i.e. players 1 to 10
- To set the end tile, find the end position and place tile 21 in enough places to fill the full width/height of wherever your map is. On the template you can see it covers the length of the map - so that the players can finish anywhere as long as they get that far. Notice it has a depth of about 14 tiles, this is not necessary but maybe two is required in case the cars are going so fast that they skip a tile before the logic loop catches up.
- Now select layer 3. The enemy car uses a path-finding algorithm to plot it's path. Because cpu time is expensive, they only look in a 40 (ish) tile radius. So when your race is large, you need to let the enemy know where to go. So at positions across the race place tiles in layer 1, starting from tile 1, onwards. look at the sample and you'll see there are about 6 way-points. Ensure the last one goes past the finish line.
- On layer 0 it's probably best to place the chequered flag on the first end spot :)
- It may be apparent now why using the onion skin and darkened background is useful.

Cup Hunt
--------
- This should be a fairly large map (the current US/main game map is 1000x500 but you don't need to make it anywhere near that big) - just big enough to make finding the cup useful
- It has three layers, but you only need to use 0 and (optionally) 1.
- The template is just a blank sea of 500x500. What would be great would be maps of countries :)


Testing in Game
---------------
1. After saving the map, place it in the levels directory
2. Edit the levels.xml file
3. Paste the following anywhere in <games> element:
    <level id="">
        <mode></mode>
        <name></name>
        <file></file>
        <startx></startx>
        <starty></starty>
        <enemies></enemies>
        <enemyvel></enemyvel>
        <highscore></highscore>
        <flags></flags>
        <countdown></countdown>
    </level>

They are all described in the levels.xml file, however to repeat:

ID: this must be unique for all maps and be a numbers. The easiest way of doing this is that all maps are stored together (all race, then all cup, etc), so find the kind of map you are creating, add your xml after the last one and increase the number by one.

Mode: 1 for survival, 3 for cup hunt, 4 for race
name: text name you give it and is displayed in the game
file: name of the map file
startx/starty: Not used for RACE types and can be ignored for them. 0 for centred on the map, -1 for random, anything else for that specific tile.

enemies: number of enemies to use in the map. For race always use 1 (can use 0 for testing), anything more will produce bizarre results.

enemyvel: the speed of the enemies (including Race game). Trial and error but the player moves at 10, if you can imagine that speed in the main game. Increase on this to make it harder, but not too much otherwise enemies will crash a lot.

highscore: the current highscore for the level. Set at 0 for no score (i.e. the first run will result in a score).

flags: Not used in survival. For Race games, this is the direction in angles the cars face (e.g. 90 for right, 0 for up, etc). For cup hunt, this is the number of cups to find

countdown: Not used in survival maps. If set to a number, this means the game is timed and counts down from this figure and the player has to finish before this time. 0 means it counts upwards with no limit.

For example, the following is a race, all players face right, there is one enemy and it is timed and the player has 10 seconds to finish

    <level id="401">
        <mode>4</mode>
        <name>Straight Run Timed</name>
        <file>race1.fmp</file>
        <flags>90</flags>
        <enemies>1</enemies>
        <highscore>0</highscore>
        <countdown>10</countdown>
    </level>
