So here's my problem:
Currently I'm developing a primitive light system for a game. The stage is overlayed with a black mask to represent 'darkness,' its alpha is then adjusted from 0 (brightest, invisible) to 1 (total darkness, opaque.) As the 'hero' gets closer to a light, I subtract the total amount of absorbed light from 1. To create a 'zone' of light around each light, with more light coming the closer the hero is, I used a quadratic expression that takes the 'distance' as the independent variable.
My code looks like this:
var boost:Number = 0;
var exponent:Number = 1-.1*(Lists.Lights.length)
for (var ii:int = 0; ii < Lists.Lights.length; ii++) {
var dist:Number = Lists.Lights[ii].getDistance()/100
var addMe:Number = -Math.pow(dist, exponent) + Math.pow(dist, exponent / 2) + 1
if(addMe>0){
boost += addMe
}
}
trace(boost)
var b:Number = brightness - boost
The problem is adjusting the exponent for the number of lights. Currently the more lights, the more severe the adjustments are. More lights = lights with shorter range. This is because all the lights are cancelling each other out, with distant lights having little to no effect.
So, should I try to restructure my code to use a different method or is there something I'm not seeing here?