2D JnR Lighting with Java2D

Hey there!

I want to implement a (not-so-dynamic) lightengine into my game.
But I don’t know how.
My Map is a simple int[][] and Tiles drawn are 16x16.

I somehow thought of a class LightEmitter, which produces light.
Every Tile has some kind of “Light Damping” which reduces the light by a certain value.
e.g. you have a light with an intensity of 16 and the tiles around it have a damping value of 2. This means the light doesn’t reach any other tiles after 8.
My Tilemap should also use a “shadow color”. Light-Value 0 is the shadow color so it doesn’t appear completely black without light.

Any Ideas How I can manipulate the appearance of the tiles? I want to implement 2 Methods:
“Hard” Lighting and Smooth Lighting

https://dl.dropboxusercontent.com/u/13341521/lightex.png

Well, the hard lighting is easy. Just create a recursive method that loops through all tiles in a radius, and set the tile light value to one minus the last one.

Smooth lighting is harder, you’ll have to do the same as above, but you’ll need to interpolate lighting by averaging the corner light values from the last tile, and setting the new tile corner light values accordingly.

An easier way would be just to overlay an image on top of your tiles that simulates the lighting, but that’s not fun is it? :wink:

Well, I know that, the thing is I don’t know how.
I only find tutorials “how to colorize a grayscale bufferedImage” etc. not how to manipulate bufferedImages with colors…

Well, do you know how to get the pixels from a spritesheet and put them into your bufferedimage? Then you know how to manipulate individual pixels. You’ll need to set up a tile like class that will represent the lighting, and then you can set the color of that light tile. Can I see an example of how you render tiles?