public class PlayerView implements MapView {
private BufferedImage image; // tiles are rendered into this image
private int[] imagePixels;
public PlayerView( /* … */ ) {
// …
this.image = new BufferedImage( // …
this.imagePixels = // get pixels from this.image
}
// renders all visible tiles to this.image, then
// for each visible tile calls applyLight( tile.x, tile.y, light )
public void update( int x, int y, int maxRadius ) { /* … */ }
private void applyLight( int x, int y, float light ) {
// multiply the color values of this.imagePixels in range
// ( x -> x+tileSize, y -> y+tileSize ) with light
}
public void draw( Graphics g ) { g.drawImage( this.image, 0, 0, null ); }
// …
}
I’m wondering whether there are any better ways of doing this. Any ideas?