Hi again
I will post the code first and explain then:
BufferedImage bL;
Graphics2D bLG;
double darkness = 155;
double dd = 0.5;
private void drawLightsAndNight(Graphics2D g) {
/*||Created on 23.07.2008 14:32:53||*/
/*°°°[ composite so that overwrite completely ]°°°*/
bLG.setComposite(AlphaComposite.Src);
/*°°°[ darkness drawing ]°°°*/
darkness += dd;
if(darkness >= 255 || darkness <= 0){
dd *= -1;
}
bLG.setColor(new Color(0,0,0,(int) darkness));
bLG.fill(bounds);
/*°°°[ lights within darkness ]°°°*/
bLG.setComposite(AlphaComposite.Src);
int k = (int) (Math.random()*10);
int h = (int) (Math.random()*10);
Ellipse2D.Double el = new Ellipse2D.Double(100-k/2,100-k/2,200+k,200+k);
bLG.setColor(new Color(255-h,255-h,155+h,25));
bLG.fill(el);
/*°°°[ go onto screen ]°°°*/
g.drawImage(bL,0,0,null);
}
This gives less than 1 FPS…
–> bounds is a Rectangle with size 1280*1024
but that shouldn´t be a problem.
I want to draw some tiles on the screen and
set this image here above so that at night
you see the tiles which are unlightet only behind
a dark “curtain”.
The parts within the lights should be visible.
How can I do this without slowing down so much?
Is there a better way ?
I guess someone here in a gaming forum should already have
much experience with lighting
Please help me.