Retro of the Week Logo
Might be useful to someone: Line of sight testing in a 2D tile based game
Posted by Billy
Posted on 28 May, 2014 at 4:56PM ↑ 1 ↓ 0

The following C++ function does line-of-sight testing for a 2D game that uses tiles. The level map is a multidimensional array of integers (levelmap[LEVEL_HEIGHT][LEVEL_WIDTH]) that represent each tile; 0 signifies and empty tile, any number higher than that is solid. A vector2 is just a datatype that contains an object's x and y position.

// Check line of sight between two points (usually the camera/player)
Continue Reading »