Skip to content
0:00 / 0:00

#roguelike#fieldofview#shadowcasting

(roguelike) grid based shadow casting / field of vision

zloedi

41 subscribers • 1 video on Hallway

YouTube
  • Recommended by 1 person: 1 on Stack Overflow and its sister sites.
  • May be out of date. Uploaded 9 years ago, in an area where tools change fast.

Intermediate. Assumes working knowledge.

2.6K views9 years ago1 recommendation

Game developmentComputer scienceGame programmingAlgorithms

A demonstration of an efficient grid-based shadow casting and field of vision algorithm implemented in C.

Efficient (roguelike) grid based shadow casting / field of vision in a single C function ver 2.0. Uses "frustum rays" to define visible volumes instead of tracing each pixel (minimal processing per pixel). Symmetrical / steps on pixel centers, optional lit walls and attenuation. Source code here: gist.github.com/zloedi/9551625 Live demo: zloedi.github.io/grid_fov/

Why it's here

1 person recommends this

What people say. Recommended as a working implementation of a grid-based line of sight algorithm for 2D roguelikes.

Stoikoon Game Development Stack Exchange • Recommends

On “More efficient way to implement Line of sight on a 2d grid with ray casting?”

I have implemented the algorithm suggested by Jimmy. Video of the code in action here: link to this video /* What this code does: Rasterizes a single Field Of View octant on a grid, similar to the way FOV / shadowcasting is implemented in some roguelikes. Clips to bitmap Steps on pixel centers Optional attenuation Optional circle clip Optional lit blocking tiles To rasterize the entire FOV, call this in a loop with octant in range 0-7 Inspired by http://blogs.msdn.com/b/ericlippert/archive/2011/12/12/shadowcasting-in-c-part-one.aspx */ static inline int Mini( int a, int b ) { return a < b ? a : b; } static inline int Maxi( int a, int b ) { return a > b ? a : b; } static inline int…