I just want to introduce a game called ‘Firefighter – The Mission‘ that can be played here. It’s somewhat a milestone for me because it’s the first game I coded as a freelancer. It was finished at the end of last year, but was just published now. The game is build upon an efficient isometric game (which you probably won’t notice that much because the animated fire and smoke effects are serious performance killer).
A unique game feature is the collision detection. All collisions are computed in 2d, so the game does not need coordinate space transformations (rotation about y and x axis). In fact, 90% of the code only uses additions, multiplications and bit shifting, so I think it should also run well on mobile devices.
Collision handling is divided into two parts, which are often referred to as broad phase and narrow phase. The broad phase step just checks if the 4 adjacent tiles on which the player stands are walkable and adjusts the player position accordingly. The narrow phase step uses a system I like to call ‘Micro Collision Cells’. Every tile has a fine grid of cells – much smaller than the player itself, and each cell can be turned on/off in the level editor. When the engine is fired up, all flagged cells are merged into the smallest possible amount of larger axially aligned bounding boxes (AABB). For example, if a tile has a resolution of 5×5 cells, and each cell is flagged, the engine would have to check 5×5 = 25 cells in total, but the simplification leads to one box covering the full tile.
Another feature I worked on was exact line-of-sight computation. This is used to get a valid range of tiles in front of the player that can be extinguished (very important for z-sorting the water particles). Scrolling is tile based and follows the principle of tonypa’s well known tutorial about tile based games.
Because there wasn’t much time to develop the game, I left out some advanced features like ‘line of sight’ for visibility determination (similar to a fog of war in strategy games), but I will definitely port and extend the engine to AS3, since it is easily adapted to other graphics sets or tile sizes which should come in handy if a similar project comes along.