Search code examples
javascriptphaser-frameworkpixi.js

PixiJS - Absorbing Light and Dynamic Audio based on Location


I want to create a game where lighting and sound is curcial. I need directional lights that can be blocked by objects e.g. walls or other players (dynamically obviously). It seems like I want to have something like this enter image description here

Is this possible with PixiJS ? If so - how ? I currently do not understand how this is supposed to be implemented. I guess this is a start - but how do you block or absorb the light?

Futhermore: I need dynamic audio. So the volume needs to decrease the futher its source is away (optional: audio volume coud be decreased by objects e.g. walls)

Is this possible with PIXIJS ?

If its not possible with pixijs ? Is there a similar lib, that can do it ?


Solution

  • So the solution for me was implementing a ray casting algorithm.

    I would strongly recommend visiting redblobgames visibility tutorial.

    Or check out sight and light.

    I also implemented the pixijs.sound package and used the stereo filter to create some kind of "dynamic" or "directional" audio.