I have a working light system for the game but it causes a little bit off lag and cant shake it, any suggestions?
package com.horizon.game.gfx;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import com.horizon.game.horizon;
import com.horizon.game.entitys.Player;
public class Light {
private int x;
private int y;
private int radius;
private int intencity;
private BufferedImage image;
public Light(int x, int y, int radius, int intencity) {
this.x = x;
this.y = y;
this.radius = radius;
this.intencity = intencity;
image = new BufferedImage(radius * 2, radius * 2,
BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = (Graphics2D) image.getGraphics();
int step = 4;
int numSteps = radius / step;
g2.setColor(new Color(0, 0, 0, intencity));
for (int i = 0; i < numSteps; i++) {
g2.fillOval(radius - i * step, radius - i * step, i * step * 2, i
* step * 2);
}
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getRadius() {
return radius;
}
public int getIntencity() {
return intencity;
}
public BufferedImage getImage() {
return image;
}
public void render(Graphics2D g2, int width, int height,horizon horizon) {
Player p = horizon.getGame().getPlayer();
g2.drawImage(
image,
(width / 2)
- image.getWidth()
/ 2
- ((p.x * horizon.SCALE) - (((x * 16) + 8) * horizon.SCALE)),
(height / 2)
- image.getHeight()
/ 2
- ((p.y * horizon.SCALE) - (((y * 16) + 8) * horizon.SCALE)),
image.getWidth(), image.getHeight(), null);
}
}