Tile Maps: Teleportation/Doors

Hi guys

I've done a few Posts here and now I have another question ^^

So: I'm saving my .map files in the asset/maps/ Folder. The .map file contains a lot of numbers in the Format of TileID:TypeID. TileID is the Image, TypeID is the type (like solid or platform). Going with this Approach, how could I add teleportation tiles?

I somehow Need to define which tile would port where (like for e.g. when entering a house). Any ideas?

My greetings.
Your map file will need to become more sophisticated.

Every tile has multiple pieces of information attached to it. You should have a bit in there somewhere that indicates that it is a teleportation tile.

Elsewhere you need a lookup mapping (or at least a list) of coordinates from to to that your game can consult whenever the player steps on a teleportation tile.

This information can be stored at the end of the map file as a list of from/to coordinate pair pairs.

Hope this helps.
Duaos: +1

You're best bet will be to make your map format a little more complicated, as Duaos said.

I have been working with tilemaps a lot lately and I have found the TMX format to be very useful. There is a really good tilemap editor associated with this format called Tiled.

Tiled Map Editor: http://www.mapeditor.org
TMX Format Documentation: http://doc.mapeditor.org/reference/tmx-map-format/

The TMX format utilizes XML to create a very dynamic and useful format to represent a lot of different things. What I have been doing is to do what Duaos said and create Portal tiles. However, each different "object" on the map, you can give custom properties and so you can give it a location to teleport to as well as set of coordinates, etc.

You will need to learn how to parse XML in general before specifically parsing TMX. However, there are plenty of XML parsing libraries available for open source use. My personal favorite is TinyXML2. It is very lightweight (only two files to put in your project) and also very well documented. You need only use it to parse the TMX format to load your data.

TinyXML2: https://github.com/leethomason/tinyxml2

If you need some help understanding it, feel free to PM me. I have had quite a bit of recent experience in tile engines.

-------------------------------------

Also, depending on your graphics engine, I have been working a lot lately on a fully functional tile engine that uses TMX as a map format. It uses SFML (http://www.sfml-dev.org) to render the graphics and handle events. You are more than welcome to use it or try it out if you like. Just let me know.

EDIT: Added information to TinyXML
Last edited on
Your map file will need to become more sophisticated.

I think the same. I'm not quite happy with this Approach, though it works just fine. Do you have better Options to store the maps? Do you save them in -txt files in simple integers as well?

How do professional programmers save their maps? (still talking about the old School tile maps)

Elsewhere you need a lookup mapping (or at least a list) of coordinates from to to that your game can consult whenever the player steps on a teleportation tile.

I like that one, so whenever the Player touches a teleportation tile, ill let the code calculate the x/y position of the touched tile and then load the new map and output the player on the new destination tile 
The file will look quite ugly then, which doesn’t really matter. It’s definitely something worth trying.


I'd love to hear some more suggestions :)
Topic archived. No new replies allowed.