So I'm making a basic 2D game in C# XNA. I want it so wherever my character is facing there is a cone of light and only that part of the level is visible while the right of the screen is dark. Please excuse my ignorance, I haven't been working with C# too long.

  • 1
    \$\begingroup\$ Have you done any reading on 2D lighting in general? That would be a good place to start. \$\endgroup\$
    – ashes999
    Commented Dec 13, 2012 at 23:05
  • \$\begingroup\$ Take a look at Catalin's Game Development Blog catalinzima.com/samples/dynamic-2d-shadows \$\endgroup\$ Commented Dec 14, 2012 at 16:36

1 Answer 1


Well the simplest approach to this would be to simply overlay a dark mask over the right side of the screen. You could do this with a completely opaque black image that covers stuff from view, but I think what would look better is a semi-transparent black image so that you can still see the background and then hide the enemy graphics on that side of the screen.

  • 3
    \$\begingroup\$ With the modification of rotating the cone to follow the view of the character, this is going to be the best solution. \$\endgroup\$
    – House
    Commented Dec 13, 2012 at 23:36
  • \$\begingroup\$ I imagined a solution with multiplication against a lighting map, but this is actually simple and very effective. +1 \$\endgroup\$
    – ashes999
    Commented Dec 14, 2012 at 0:54
  • \$\begingroup\$ I'm a little confused about what you mean. Are you saying that I should lay a semi transparent black image for the entire screen? How would the cone vision with this method? \$\endgroup\$
    – Ady
    Commented Dec 14, 2012 at 1:48
  • 2
    \$\begingroup\$ @Ady yes, that's what he's saying. The cone would be a transparent area in the black image; rotate and position it to always point from the player to wherever he's looking. \$\endgroup\$
    – ashes999
    Commented Dec 14, 2012 at 3:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .