Navigation
News
Theory and documentation
Version history and plans
Screenshots
Download
About
Javadoc
SourceForge homepage
Last updated: 2004-02-27
|
Map framework
Status: Beta
Introduced in: 0.0
Refactorings: 2
Developed by: Freerider, Treefinger
Latest iteration in: 0.3
Latest iteration by: Treefinger
Overview
The Map hierarchy is just recently formed and the chinks might not have
been straighted out. It consists of:
- Map
An abstract class able to represent any kind of map.
- TileMap
TileMap extends Map into a map representation using tiles.
This class handles plain 2D maps seen from above and uses a simple
algorithm to draw them out.
- IsometricTileMap
IsometricTileMap extends TileMap and generally just supplies a
different paint routine to draw the Map isometrically. Read more about
this algorithm on drawing isometric
maps.
- Tile
Used to represent any kind of Tile. Has functionality to house items,
objects, characters and subworlds.
XML format
Both tile maps and isometric tile maps use the same XML format for loading
and saving. It has four sections:
Map information
Here is all basic information for the map defined. The entry looks like
this (for isometric tile map, for a tile map, the only different is the
exclusion of "Isometric"):
<IsometricTileMap |
name="blacksmith"
width="13" height="13"
tileSet="tilesets/default/default.xml"
tileWidth="64" tileHeight="32"
shape="2">
|
- name
The name of the map, could be anything
- width, height
The width and height (in tiles) of the map
- tileSet
Which tile set to use, defined as a Sprite file
- tileWidth, tileHeight
The width and height of the tiles in pixels
- shape
The shape of the map:
0 - Flat map
1 - Torus map (wrap both x and y)
2 - Wrap around x
3 - Wrap around y
Tile definition
This part contains definitions of the tiles that are used to make up the
map. The entries look something like this:
<Tile index="grass" treadableValue="0" elevation="0,0,0,0" spriteName="grass"/>
- index
Just an abstract name for this tile
- treadableValue
0 - characters can walk on the tile
1 - characters can not walk on the tile
- elevation
Not commonly used, used for specifying the height of the corners
of the tiles. Experimental.
- spriteName
The name of the Sprite that holds this tiles graphics. Sprites
are defined in a separate Sprite file, read more about this at
Sprite hierarchy.
Map definition
Here, you define your map using the index defined in the previous section.
Each x row on a single line.
For example:
<ground>
grass,grass,road,grass,grass
grass,grass,road,grass,grass
road,road,intersection,grass,grass
grass,flowers,road,grass,grass
</ground>
Object definition
Here you define all the objects of the map, they can be either static
objects or items. Static objects are defined as this:
<StaticObject GraphicalObject="objects/buildings/forge/forge.xml" tileX="3" tileY="2" treadableValue="1"/>
- GraphicalObject
The file to the graphical object that should
be placed.
- tileX, tileY
The location of the object in tile coordinates
- treadableValue
If you can walk on the tile after this object
is placed or not (0 - you can, 1 - you cannot)
Items are defined like this:
<Object tileX="3" tileY="3">
<Item name="Short Sword" quality="100"/%gt;
</Object>
- tileX, tileY
The location of the object in tile coordinates
- name
The name of the item, must be defined in the global
item list.
- quality
The starting quality of the item
Example map
Here is an example of a complete map! (this might not be openable in your browser since it is
xml and the dtd is not co-located here, but open it in a text viewer and it'll be fine)
|