I searched the forums for raycasting but didn't find anything useful.
Would it be possible to create a moving-shadow effect like this, where shadows change shape depending on the position of the light source?
(https://i.imgur.com/mgLRe4p.png)
I feel like it should be possible with raycasting and with using either two versions of a background (dark and light) or with simply editing a black dynamic sprite (or series of sprites) every frame, using some kind of mask. Can this be done in AGS script?
EDIT: if raycasting is too resource-intensive, I also had an idea to use overlays whose size and rotation changes with the light source position, but I feel like it would still need raycasting to determine the blocking width of non-circular objects.
Is this for actual top-down graphics? Or was that just an illustration?
I'm asking because the method and feasibility greatly depend on the type of graphics.
@Khris I actually had it in mind for things like moving a flashlight around a room. It wouldn't have to be top down necessarily but could be either first person (Myst-style, where the cursor is a torch, for example) or third person, like someone walking with a lamp.
Rendering shadows using some kind of mask is possible.
In order to do this in general you need to have a 3D model of the objects casting the shadows, of the surfaces the shadows are cast on, and of the position of the light source. You may restrict it in various ways (and use tricks and approximations) to require less data, but a freely moving light source is probably always going to be difficult to fake in 2D.
If the geometry is simple enough, you could potentially build a 3D model and calculate the shadow projections (via raycasting or some other method). Shadows of irregular objects are much more difficult, but if you have something like a character view from multiple angles, it could be possible to take the closest matching view depending on the angle, and project that outline onto the surface. (See this (https://www.adventuregamestudio.co.uk/forums/advanced-technical-forum/dynamic-shadows-in-ags-idea-for-module/) earlier discussion.)
Depending on the restrictions and simplifications that are acceptable, other solutions are probably possible. I think a small handful of AGS games have actually done dynamic shadows of one kind or another.
Whether it is a strictly flat 2D lighting where objects cast shadow areas behind them and nothing else, or a 3D emulation where object shapes matter, is a critical choice here. 2D would require basic geometry, while 3D emulation would need something like a 3D model or a normals map.
I think that this recent game by Radiant uses 2D grid-based raycasting for calculating visibility:
https://www.adventuregamestudio.co.uk/forums/ags-games-in-production/sherwood-7-day-roguelike-challenge/
Then there's this module for lighting using a normals map:
https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-agslighting-v1-00-normal-maps-in-ags/