Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

enter image description here

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?

share|improve this question
1  
The walls are just a visual aspect of the collisions. The tiles on the ground are where the collision detection is happening. –  Byte56 Oct 29 '13 at 22:33

1 Answer 1

up vote 4 down vote accepted

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.