How do I make realistic flashlight effect ?

Get help using Construct 2

Post » Sun Dec 22, 2013 11:53 am

Hello Scirra community, I am quite new Construct 2 and I was wondering how I can easily make realistic flashlight effect ?

I have been looking through forums and best I could find was having large image to follow you or to have image what subtracts opacity from dark image.

So I came along with my own temporary solution :


Basically all map is covered with black cubes and if player have line of sight to then, they have full opacity on them, so as all squares in radius of 75 pixels from player are visible too.

Of course this may have been better with small cubes, but it seems they glitch out a little when copying (size are same, but they dont fit).

So faster to the point - is there easier way to do this ?
To have flashlight effect what do not work through solids ?
How to make it ?

Alternative - is there way to set several lines of sight ?
For example at 75 degrees it is 0 opacity, from 75 to 90 it is 50% and from 90 to 120 it is 75% opacity and so on.. or this can be done in different way to achieve same goal ?

Thanks ,
Mr1H

Update:
The same method but with smaller cubes, problem this is really demanding for the machine and gives huge fps drop :(
http://s24.postimg.org/5cxrkutat/Untitled.png
It looks quite nice, I think it may be even more effective having enemies as obstacles for FOV too.

I am sorry about default sprites, but I rather test game that way.
Mr1H2013-12-22 18:19:28
B
3
Posts: 8
Reputation: 193

Post » Mon Dec 23, 2013 11:26 am

Hardly realistic but this was my attempt - a grid of light pinned to the player and illuminated depending on line of site. Still very heavy on cpu. Something like you are after ?



https://dl.dropboxusercontent.com/u/143636437/flashlight/index.html
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,812

Post » Tue Dec 24, 2013 10:47 am

August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,812

Post » Tue Dec 24, 2013 12:27 pm

Yea something similar, my first attempt was just having all map of these black squares, but it have me like 12-20 fps only.

I have theory in my head how it may have done better, but currently I have no time to test it, but if fps are determined only by actual blocks/sprites what are rendered each time, then way may be to determine the angle of player and if he looks for example to the right all left side is replaced by one big squere and all black squares if combine together make bigger square and so on, but still it means having sprites fallowing player in several layers and total amount of sprites will be a lot bigger, I will test that and if it goes good I will post or upload something.
B
3
Posts: 8
Reputation: 193


Return to How do I....?

Who is online

Users browsing this forum: vegapomme27 and 10 guests