Could you explain this a little more, or give an example program. I need something like this for one of my projects.
ok, every tile in a map has a number by which it can be identified, going from zero to [width]*[height], running from left to right, top to bottom(conventionally), yes? well, a similar system could be used to enumerate all the link tiles in a given map. If one were to start at the top left corner of the map and move left to right, top to bottom, each link tile could be numbered in succession to give it a unique identity. example:
map data(where 00 is a "normal" tile and 11 is a "link" tile)
[00110000
[00000011
[11001100
[11110000
there are a total of six link tiles, so they would be numbered like so
[--01----
[------02
[03--04--
[0506----
(i'm probably over-explaining this a bit, but better safe than sorry and all that)
then, to determine which tile has been stepped on, the programmer need only use a for loop which is [player's current Y in map]*[total map X]+[player's current X in map] long which searches through the map data, left to right, top to bottom, and increments a counter every time a link tile is encountered. the number stored in this counter when the for loop terminates can then be used to determine how many link tiles are in listed in the map before the one on which the player stepped, and thus the unique number for the tile on which he stepped.
axe psuedo-code
:0->C
:for(L,0,[player's current Y in map]*[total map X]+[player's current X in map]
:If {[map data pointer]+L}=[number used to define a link tile]
:C+1->C
:End
:End
:C-1->C ;because this counting method will label the first tile as link tile number 1, and we want it to be number 0
then, the programmer can store, concatenated to the end of the map data, a list which has three values for every link tile in that map. these three values are: the map to which the tile links, the link tile number in that map on which the player is to appear, and the direction in which the player is to face when he appears.
so, taking our previous example map with six link tiles:
[00110000
[00000011
[11001100
[11110000
we would have to add to the end another line which looks like this
[[map #1][tile in map #1][direction to be faced #1][map #2][tile in map #2][direction to be faced #2]...
you get the idea
then, to access this data one would only have to use
{[total map length(X*Y)]+[map data pointer]+(C*3)+[0,1, or 2, depending on which piece of information you want]}
then, to place the player in the proper position in the new map, a similar loop needs to be used:
:0->D->L
:Repeat C+1=D
:If {[map data pointer]+L}=[number used to define a link tile]
:D+1->D
:End
:L+1->L
:End
L will then contain the tile number upon which the player is to stand, and a simple operation
L^[total map width]->X
L/[total map width]->Y
returns the player's X and Y positions in that map
that was just a little bit overkill, wasn't it?