Skip to main content
GameDev.net gamedev.net
🔒 Locked

[XNA] 2D Flashlight Vision

Started by Daichi Jun 10, 2011 at 9:27 AM 2 replies 4.1k views
Original Post
Daichi
Daichi
[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
Daichi
Daichi

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.
remigius
remigius
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.