Skip to content

technical engine map

Vinorcola edited this page Dec 12, 2020 · 3 revisions

The map, the elements and the coordinate system

Map and coordinate system

The map is the object that represente a city map. This map is rectangular. It contains a certain amount of tiles. Those tiles are arranged as diagonal. Each tile match a single coordinate on the map.

Map Coordinate System

As we can see above, the northest tile start at coordinates (0|0). Going south will increase the ordinate while going west or east will respectively decrease and increase abscissa.

The map size is set in number of tiles. In the image above, the map size is horizontally 23 tiles and vertically 33 tiles.

Note that in our implementation, there is no object representing a tile. The engine is essentially working with coordinates. The map object can tell if a given coordinate is valid (e.i. is included within the map). For example, with our 23x33 sized map, the coordinates (5|4) are not valid since they are outside of the map.

Static and dynamic elements

The map pretty much has a single purpose: it contains elements. Each element on the map is set at a particular position (e.i. a particular coordinates). We can distinguish 2 types of element: the static elements and the dynamic elements.

A static element is an element that will never move. It can be destroyed though. A static element has an integer size (in number of tile) and is always positionned at integer coordinates. This mean a static element literally cover one or several tiles, but always cover those tiles entirely. For example, on the image above, the blue area could represent a static element.

A dynamic element however is meant to be moved. It does not have a particular size. But it still has a position, which can be floating coordinates while they are moving from one tile to another. For example a dynamic element moving from (0|0) to (0|1) will eventually pass through coordinates (0|0.25), (0|0.5), etc.