Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
1  
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 catalinzima.com/samples/dynamic-2d-shadows –  Luis Estrada Dec 14 '12 at 16:36
add comment

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.

share|improve this answer
3  
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
2  
@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
add comment

Your Answer

 
discard

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.