I already have a lighting system and (mostly) functional. I try to implement transparency so that certain blocks (for example, water) remove only part of the light passing through them, and it works, but it stops working with the limit of the total number of light maps (in my case, 20).
Here's what it looks like:

and here is my code:
for(int x=0;x<mapX;x++){
for(int y=mapY-1;y>-1;y--){
try{
if(map[x][y] instanceof LightSource)
lightmap[x][y]=19;
else{
else{
if(x-1>-1&&lightmap[x][y]<lightmap[x-1][y])
lightmap[x][y]=lightmap[x-1][y]-map[x][y].translucency;
if(x+1<lv.map.length-1&&lightmap[x][y]<lightmap[x+1][y])
lightmap[x][y]=lightmap[x+1][y]-map[x][y].translucency;
if(y+1<lv.map[0].length-1&&lightmap[x][y]<lightmap[x][y+1])
lightmap[x][y]=lightmap[x][y+1]-map[x][y].translucency;
if(y-1>0&&lightmap[x][y]<lightmap[x][y-1])
lightmap[x][y]=lightmap[x][y-1]-map[x][y].translucency;
}
}
}catch(Exception e){}
}
}
Does anyone see what I'm doing wrong? Is there any other system that I could use to support transparency? Can anyone tell me at least why this is happening?
source
share