• Advertisement
Sign in to follow this  

[XNA] 2D Flashlight Vision

This topic is 2451 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[font="Calibri"][font="arial, verdana, tahoma, sans-serif"][font="Calibri"]Okay, so I have a simple 2D tile-based top-down game.[/font]

[font="Calibri"]I have these guards that are trying to spot the player. They have a field of view that I want to represent as a flashlight glow that lights up the area. This area will be where the guard can see, so I'll also need to detect if the player is inside one of the guards' views. Tiles can also block their vision.[/font]

[font="Calibri"]I guess I want something to look like this:[/font]
[font="Calibri"][attachment=2975:flashlight_vision.png]
[/font]
[font="Calibri"]I've seen stuff about ray tracing or field of view, but I'm not sure where exactly to start first. [/font][/font][/font]mellow.gif

Share this post


Link to post
Share on other sites
Advertisement

Does this tutorial help?


Do I actually need something this complicated? I don't necessarily need to cast light in all directions, just at a specific angle of view. heck, I don't even need to cast shadows, only a light overlay.


I should also specify that I'm trying to target WP7, which I think has problems with custom shaders.

Share this post


Link to post
Share on other sites
Ah yeah, for WP7 custom shaders won't work. I'm a bit out of the loop, but I think the phone just doesn't allow custom shaders at all (for now).

I can't seem to think of anything much simpler though. Whether you're casting shadows or light, the basic problem is the same. If you want the light to be occluded, the only techniques I can come up with are 2D versions of shadowmapping or shadow volumes. I did find this tutorial and this engine that might both offer good ways to create 2D shadows.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement