So, I’ve been toying around with dynamic tilemap lighting, and it’s going okay-ish, but I can’t wrap my head around combining lights. As of now, each tilemap holds values of the lighting of each individual tile, from 0 - 255. 255 being completely black. So anyway, here’s a screenshot of the problem:
http://img690.imageshack.us/img690/5263/dynamiclightingrev1.png
Essentially the bottom-right image shows when a light below it collides with a light above it…the bottoms lights fade overrides the above lights brightness.
Here’s the code, it’s simple so I’ll put it all up:
public void checkLighting(int x, int y){
if (mapTiles[3][x][y] < 255){ //Checks if the tile is lit up.
for (int c = 1; c < 10; c++){ //Diagnally ascending variable, breaking it into levels.
for (int a = 0; a < (c*2)+1; a++){ // Takes each "level" and goes right and down
try{
//Sets lighting that of the original tile and makes it darker by 20*c. Same with the rest.
mapTiles[3][x-c+a][y-c] = (mapTiles[3][x][y] + (20*c));
mapTiles[3][x+c-a][y+c] = (mapTiles[3][x][y] + (20*c));
}catch(Exception e){} //To prevent error from leaving bounds of tilemap.
}
for (int b = 0; b < (c*2)+1; b++){ //Takes each "level" and goes left and up
try{
mapTiles[3][x-c][y-c+b] = (mapTiles[3][x][y] + (20*c));
mapTiles[3][x+c][y+c-b] = (mapTiles[3][x][y] + (20*c));
}catch(Exception e){}
}
}
}
}
Any tips on fusing the lights? Help is greatly appreciated