Help with light and darkness

Started by Diarandor, September 20, 2014, 03:28:31 AM

Previous topic - Next topic
Hi,

I would like to know if it is possible to program dark rooms where there are several sources of light (including the hero, some moving enemies, and torches on walls). Outside the illuminated areas there would be opaque darkness. Is it possible to do this? And how?

Thanks for your help!!!
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

I don't believe it is currently, as I also need this for my game. The current approach to darkness/light is to apply a dark sprite over the whole screen, with a transparent area in the middle which appears as "light" (and can follow the hero, such as with the lamp). The problem is that you can't apply multiple lights because there is no actual light, only a lack of darkness in a small area. If you had pre-arranged areas of light, I suppose you could do multiple "cut-out" areas in the dark sprite, but this can't be done dynamically.

Eventual implementation of shaders in the engine could allow for more advanced lighting effects.

I confirm wrightmat's answer.
We have an issue for this: https://github.com/christopho/solarus/issues/466
surface:get_pixels() and surface:set_pixels() is a first good solution: you could at least build your own darkness mask.

Thanks a lot again for your help!
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."