# Wall between tiles

**URL:** <https://forum.kirupa.com/t/wall-between-tiles/264422>\
**Category:** Uncategorized\
**Created:** [June 26, 2008, 12:03am UTC](https://forum.kirupa.com/t/wall-between-tiles/264422 "2008-06-26T00:03:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ignasimg](https://avatars.discourse-cdn.com/v4/letter/i/47e85d/32.png) [@Ignasimg](https://forum.kirupa.com/u/Ignasimg)\
**Post date:** [June 26, 2008, 12:03am UTC](https://forum.kirupa.com/t/wall-between-tiles/264422/1 "2008-06-26T00:03:19Z")

</div>

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:  
 ![](http://www.kirupa.com/forum/attachment.php?attachmentid=47034&stc=1&d=1214438207)  
(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? 😛

---

<div class="post-metadata">

**Author:** ![Fidodo](https://avatars.discourse-cdn.com/v4/letter/f/779978/32.png) [@Fidodo](https://forum.kirupa.com/u/Fidodo)\
**Post date:** [June 26, 2008, 12:46am UTC](https://forum.kirupa.com/t/wall-between-tiles/264422/2 "2008-06-26T00:46:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dlgamer](https://avatars.discourse-cdn.com/v4/letter/d/7993a0/32.png) [@dlgamer](https://forum.kirupa.com/u/dlgamer)\
**Post date:** [June 26, 2008, 3:52am UTC](https://forum.kirupa.com/t/wall-between-tiles/264422/3 "2008-06-26T03:52:42Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![Ignasimg](https://avatars.discourse-cdn.com/v4/letter/i/47e85d/32.png) [@Ignasimg](https://forum.kirupa.com/u/Ignasimg)\
**Post date:** [June 26, 2008, 3:04pm UTC](https://forum.kirupa.com/t/wall-between-tiles/264422/4 "2008-06-26T15:04:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dlgamer](https://avatars.discourse-cdn.com/v4/letter/d/7993a0/32.png) [@dlgamer](https://forum.kirupa.com/u/dlgamer)\
**Post date:** [June 26, 2008, 3:13pm UTC](https://forum.kirupa.com/t/wall-between-tiles/264422/5 "2008-06-26T15:13:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Charleh](https://avatars.discourse-cdn.com/v4/letter/c/a9a28c/32.png) [@Charleh](https://forum.kirupa.com/u/Charleh)\
**Post date:** [June 26, 2008, 3:14pm UTC](https://forum.kirupa.com/t/wall-between-tiles/264422/6 "2008-06-26T15:14:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ArmoredSandwich](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@ArmoredSandwich](https://forum.kirupa.com/u/ArmoredSandwich)\
**Post date:** [June 26, 2008, 8:35pm UTC](https://forum.kirupa.com/t/wall-between-tiles/264422/7 "2008-06-26T20:35:12Z")

</div>

> [@Charleh;2349637](#):
>
> 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

---

<div class="post-metadata">

**Author:** ![bpalermo](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@bpalermo](https://forum.kirupa.com/u/bpalermo)\
**Post date:** [June 30, 2008, 10:39pm UTC](https://forum.kirupa.com/t/wall-between-tiles/264422/8 "2008-06-30T22:39:56Z")

</div>

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… 🙂
