Skip to content
0:00 / 0:00

#shadowcasting#lineofsight#2dgraphics

Line Of Sight or Shadow Casting in 2D

javidx9

332K subscribers • 7 videos on Hallway

YouTube
  • Recommended by 1 person: 1 in engineering communities.
  • Presented by javidx9
  • Linked in the descriptionOneLoneCoder/Javidx9
  • May be out of date. Uploaded 8 years ago, in an area where tools change fast.

Intermediate. Assumes working knowledge.

151K views8 years ago1 recommendation

Game developmentGraphics and audioGame programmingRenderingAlgorithms

javidx9 demonstrates how to implement a 2D line-of-sight and shadow-casting algorithm in C++ using the PixelGameEngine.

In this (long, sorry) video I cover a variety of things to implement a classing line-of-sight mapping, or shadow casting depending on your perspective. It's also the first olc::PixelGameEngine project I've done a video for, so I spend some time showing you how to set up Visual Studio to use this engine. I'm quite pleased with the end result of these algorithms and I expect to use them quite a bit in more ambitious tile-based projects in the future. These resources are excellent regarding the things seen in the video: stackoverflow.com/questions/563198/how-do-you-detect-where-t… redblobgames.com/articles/visibility/ ncase.me/sight-and-light/ Source: github.com/OneLoneCoder/Javidx9/blob/master/PixelGameEngine/… discord.gg/WhwHUMV Blog: onelonecoder.com Twitter: @javidx9 Twitch: javidx9

Why it's here

1 person recommends this

What people say. Recommended as an excellent tutorial for implementing 2D shadow casting and visibility algorithms.

u/s0llyin r/programming • Recommends

On “My Attempt at a Shadow Casting Algorithm”

I got the idea of attempting Shadow Casting in a game through this excellent video: [video I've however approached things slightly differently - using straight line calculations rather than raycasting, and "edge" elimination techniques - and am quite happy with the results (although I need to combined edges, still). There are very few instances of artefacts cropping up but I'm planning on ironing those out. Otherwise, I aim to more generally apply the algorithm to all objects in the game space that "emit" light, as their light sources still leak through walls (i.e. aren't clipped via shadow casting). Quite the difficult journey, but enjoying it!