Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Have you done any reading on 2D lighting in general? That would be a good place to start. – ashes999 Dec 13 '12 at 23:05
Take a look at Catalin's Game Development Blog – Luis Estrada Dec 14 '12 at 16:36

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.

share|improve this answer
With the modification of rotating the cone to follow the view of the character, this is going to be the best solution. – Byte56 Dec 13 '12 at 23:36
I imagined a solution with multiplication against a lighting map, but this is actually simple and very effective. +1 – ashes999 Dec 14 '12 at 0:54
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? – Ady Dec 14 '12 at 1:48
@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. – ashes999 Dec 14 '12 at 3:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.