# How do I detect collision with isometric walls?

I will use game called "Project Zomboid" as an example. Here is a pic how does it look >

How should I handle player's collision with walls constructed like that? It's easy to handle walkable and not walkable tiles for player, but this is different and I have no ideas how to solve this problem. Any tips?

• The walls are just a visual aspect of the collisions. The tiles on the ground are where the collision detection is happening. – MichaelHouse Oct 29 '13 at 22:33

## 1 Answer

Store flags for the edges of tiles, not the whole tiles. For instance, the "Southeast Wall" tile might have the flags SouthWall and EastWall set. When doing collision tests, check the boundaries you're crossing, not the whole tile.

Alternatively, for even more flexibility, store both tiles (floors) and the boundaries/walls in separate or interleaved arrays. If interleaved, you'd have walls/boundaries in the even spaces (0, 2, 4, 6, etc.) and tiles in the odd spaces (1, 3, etc.) with every map being an even size (every tile is surrounded by boundaries). This works if your tiles and boundaries are roughly the same in terms of data. Separate structures works just fine, too. The advantage to this approach is that you can have tile/floor data separate from wall data and each wall is its own entry, so you can more easily mix-and-match walls and floors.

A further simplification is to still have tiles, with each tile now have two wall fields, say upper-left and upper-right (the other two sides are the walls from the tiles below).

This approach has been used in some non-isometric 3D tile-based games as well (think Dungeon Master, Grimrock, Stonekeep, etc.) that wanted to encode data in the walls in addition to data in the floors, e.g. to have a cubby in the north wall and a separate cubby in the east wall but no cubby and walkable floor on the other side of the walls.

• Thanks for clear and detail answer. I understand it now. – Tom Oct 30 '13 at 1:05