How do I make realistic flashlight effect ?

0 favourites
  • 4 posts
From the Asset Store
2D realistic cloud pack has 11 different clouds included.
  • 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 :

    <img src="http://s21.postimg.org/rqv51ax4n/Untitled.png" border="0" />

    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 :(

    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.

  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)