Wall between tiles

hello, maybe the title is a bit. . . odd but i’ll try to explain my best, i’ve been thinking about a game (tile based) and i’d like that there were certain walls between tiles (in the line that divides them) for example:

(image taken from tonypa tutorials and modified myself)

i’d like that the hero could move everywhere but not throught the red lines
(whitout hitest operations)
so far i can think about how to put the walls in their sites, but i have no idea of how to do that in an easy way, my only idea about doing that simple is doing the map, later a pathfinding of nodes, and remove the nodes that cross the wall, but i think that in a big map would be much more slow, so…
any ideas? :stuck_out_tongue:

One way would be to give the tile a special code so they are only passable from certain directions. There might be a more elegant solution though.

  1. create 3 matrixes (I’ll just make up some names for this post):
    [LIST]
    []mapTiles - stores the actual tiles
    [
    ]mapHWalls - stores top + bottom walls
    [*]mapVWalls - stores left + right walls
    [/LIST]

  2. keep track of your heros location in rows + columns

  3. Then testing each side would be as simple as:
    [LIST]
    []Up - mapHWalls[heroRow][heroColumn]
    [
    ]Down - mapHWalls[heroRow][heroColumn+1]
    []Left - mapVWalls[heroRow][heroColumn]
    [
    ]Right - mapVWalls[heroRow+1][heroColumn]
    [/LIST]

the purpose of fidolo is good but as he/she said there might be a more elegant sollution

the dlgamer one seems more elegant but i don’t like the idea about having 3 matrices (nor having a matrix of matrices)
and the part to test each side in my opinion I think in large maps it’ll become slow

you wouldn’t have to test each side, just the side to want to exit the tile from

Just add a property to the tile object which determines the location of the walls. You could use a bitmask or an enumeration as there are only 16 possible combinations of wall locations on a single tile.

There’s enumeration in actionscript??? xD

I don’t know how slow it would run, nor can I measure how much elegant this solution would be, but… I’m no programmer, so, I’m only giving it a try.

Why not using strings instead of numbers for the tile types. They would be four character strings, formed by 0 for an exit side and 1 for a blocked side using the format “top down left right”, thus, “1110” would be a tile you can only exit through the right, while “1010” could be left by the bottom or the right.

In fact, as an afterthought, you could use decimal numbers and convert them to binary to get the coordinates if you like.

Anyway, I’m feeling I’m talking bulls**t, but, then, I may, luckily not… :slight_smile: