-
Notifications
You must be signed in to change notification settings - Fork 41
Mapmaking
Last updated for v0.13 (WARNING: out of date. Flare's entire map system can be edited within Tiled now. We'll update this tutorial soon. -Clint)
Here's a quick primer on editing maps for Flare.
I strongly recommend studying existing maps before making your own! If you don't configure things properly you could end up with a map that has to be thrown away.
The map editor is called Tiled
Look in the /tiled/ part of Flare's source tree. It contains several png files and tmx files. Grab a local copy. Open any of the tmx files in Tiled to see how they look.
There are several important settings at play:
- The total map size can be up to 256x256
- Isometric view is required
- The map grid size is 64x32
- Three tile layers: background, object, collision
- Two tilesets: the collision tileset must be first, then the tileset for that map
- The tile size for the tileset is 64x128
The tile sizes settings are important, as well as having the collision tileset first. If this isn't set up properly, all the tile IDs will be shifted and the map won't work.
Background contains floor tiles.
Object contains wall tiles as well as various obstacles.
In-game, the entire background layer is drawn first, then the object layer is drawn on top of it. All enemies, missiles, heroes, etc. are drawn inline with the object layer.
The collision layer is a special case. Only collision tiles should be used here.
- Red square means this tile blocks all movement, sight, and flying things.
- Blue square means this tile blocks movement, but not sight nor flying things.
- Half tiles are not currently used.
- The faded red tile is like a regular red tile, but it is invisible on the mini map. Useful for filling in negative space or for outlining secret passages.
In Tiled Preferences, apply this setting: Store tile layer data as: CSV
Save your map as a TMX file.
Flare uses .ini style map text files. Edit any of the existing maps to see the format. You'll have to copy comma-separated value (CSV) data from the Tiled tmx file into the Flare txt files. Each Flare map has a background, object, and collision layer just like in Tiled.
Example header:
[header]
title=Averguard Academy
width=70
height=100
tileset=tileset_dungeon.txt
spawnpoint=62,3,7
music=town_theme.ogg
- title is shown at the top-right of screen during play
- width and height must be set to match the Tiled map size. Again, max is 256x256
- note the tileset refers to a file in tilesetdefs/
- spawnpoint is tile x, tile y, facing direction
- music refers to a file in music/
Example layer data:
[layer]
id=background
format=dec
data=
- id must be background, object, or collision
- format must be dec if copying layer data from Tiled. Flare also supports 2-digit hex format, which is easier to manage in plain text because the columns all line up.
- data= should be followed by a line break, then the CSV data for that layer pasted from the Tiled tmx file.
Currently all events are added to the map .txt files manually.
Each event has a type, location, and up to 8 more lines of Event Components. (to do an event with more than 8 components, overlap several smaller events)
Example teleport event:
[event]
type=teleport
location=62,2,2,1
intermap=averguard_atrium.txt,9,57
- type=teleport
- location is the activation area. tile (x,y) and tile span (w,h).
- intermap tells the engine that this teleport leads to a different map file, at the target tile location.
Example run_once event:
[event]
type=run_once
location=31,22,1,2
mapmod=object,31,22,165
soundfx=soundfx/inventory/inventory_page.ogg
msg="Some say the Averguard Academy is the greatest collection of knowledge within the empire."
- type=run_once
- location is the activation area. tile (x,y) and tile span (w,h).
- mapmod changes the current map. which layer, then tile (x,y) and the new tile id. This can be done for the background, object, and collision layers.
- soundfx tells the engine to instantly load and play that sound
- msg tells the engine to display this text in the HUD log.
Another run_once event example:
# boss tomb
[event]
type=run_once
location=3,89,3,4
msg=This tomb glows with magical runes.
loot=random,5,90,5
loot=id,5,91,2
shakycam=30
- loot spawns an item and puts in on the floor.
- loot can be random or a specific loot id
- the first pair of numbers is the tile (x,y) to spawn the item.
- the last number is the Loot Level on random loot, or the item id on specific loot.
- shakycam shakes the screen for X frames.
Currently all enemiesare added to the map .txt files manually.
[enemy]
type=skeletal_mage
spawnpoint=30,63,0
}}}
- type refers to an enemy map file name (minus the .txt)
- spawn point is (x,y) and facing direction
Place your new map .txt file with the others in the map/ folder.
To test a map you can edit your save file and set your spawn for your new map.
There is still a lot of manual editing required to make maps. I'm pretty sure Events and Enemies could be done using Tiled's object layers, but for now that stuff is manually added to each map plaintext file.
Tiled allows plugins to add read/write support for new map formats. Jaderamiso created a simple Tiled plugin that reads/writes the basic Flare format for layer data. It should be possible to add features to that plugin so that 100% of the map info can be edited within Tiled.
Another option would be to simply parse the Tiled XML format (CSV option for layers) for Flare. Last Escape does this using the lightweight TinyXML library.
Tiled has some new fancy AutoMapping that could be applied to each Flare tileset. It would make drawing walls very easy. I just haven't dug into it yet. If someone wants to test out the Tiled AutoMapping on Flare's dungeon or cave tileset I'd be very interested to see that.