0 favourites
  • Thanks, I'll check it out!

  • I played with making 2D minecraft style and lighting a while back, still have the source if interested?

    Not sure if it could help at all?

    Demo here:


    WASD and Mouse. There is a ambient light that follows the player and you can place lamps, also has dynamics shadows.


  • Very cool. If you don't mind sharing the source, I would take it.

  • AllanR

    I think I already have that project file and it's not really what I was looking for, but thanks anyway.

  • bump.

  • Had a go at attempting to replicate the effect, since it's not super clear how it works. I used C2 and the paster plugin for drawing and compositing. C3 may be able to do the drawing in some other way.

    My first attempt just used a shadowcaster blended with a radial gradient to do the shadows. Made lowres with a lower res paster object. The next step would be to do some kind of bloom to feather the lit area to light the surrounding walls. Maybe could be done with a shader, maybe. Anyways, I stopped there.


    The next test did a kind of weighted flood fill to expand light gradually outward from a mouse click. When a wall is hit it wouldn't stop the light but make it reduce quicker. Used sprites as a test and only runs on a click.


    The third test used a weighted flood fill as well but in a different way. It referenced a tilemap for walls and used some arrays to keep track of stuff while flood filling. Paster was merely used here to draw the shadow area. The lit area is carved out with a destnation-out blend.


    A hybrid between the first and third could look alright. Colored lights could be done with more blending modes with paster instances to do the multiple steps one by one. In C3 you may just need apply the ideas in a similar but different way since paster doesn't run there.

    Anyways just some ideas.

  • Sorry, when I aid in my earlier post that I have the source which you can have.. I should of checked i actually did have it!

    I never every delete old project files but I had realised I did this in C2 and have used C3 for over a year now so I have at a bit of a loss as to where my older C2 project files are.

    I will keep on searching, once found I will be sure to upload it for you.


  • Wow! You guys are awesome! Thank you!

  • R0J0hound

    I do not have the paster plugin. I have your other 'canvas' one in C2 for a project I had to open a while back. So far I have been using the second example. Is there any way to do a light strength? For example, if the strength was 1, it would light up one or two blocks. 2 would light up two of three blocks, ect. I would think you could do a function with a parameter called 'brightness'. And then when you click it will call the function with either a set or random brightness.

    Anyway the example is very good. Also would it would be possible to migrate the third example into the 'canvas' plugin so I could open it? If so it would be appreciated.

    Thank you

  • Canvas is obsolete, but here is the third example done without paster at all:


    Paster just lets it blend more.

  • That's really neat r0j0

  • WackyToaster


    I wasn't satisfied with the diamond shape, so here it is more rounded. Octagonal really. Also changed the falloff rate of light.


    Another tweak to see if i could make it cast shadows instead of wrapping around as much. Ended up looking the same, but should do less checks.


  • That is utterly AWESOME!!! If nobody ever mentioned you were a genius I just did. . . Thank you sooooo much!

  • Is there a way to change the light strength? Or color?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can change the "steps" variable to control the strength of the light. The default is 20, which makes a 20*8 or 160 pixel radius light.

    Color light is probably done the same way you'd color lights with the shadow caster.

    Here's one way that doubles the amount of objects. Basically a layer to do the shadow, and another layer with the light color which is blended with the scene. This also animates the color and strength of the light.


    Multiple lights would be done by doing each light separately and combining the shadow and color layers of each. As is the performance isn't good enough to do that. Also I'd want to reintroduce something like paster to handle the mixing instead of juggling layers.

    It's as far as I'll go with this for now. A significant speedup can be done by doing the floodfill algo with javascript, and the drawing should be simpler/faster to draw directly to textures for the shadows and colors. Less overhead at least, not my cup of tea to do that mixed with construct though.

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