Hm, how can I improve my rendering? the fps falls when I have around 100 towers on the screen.
Here’s my tower render method:
AlphaComposite trans = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f);
AlphaComposite solid = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f);
@Override
public void render(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
for(Entity e : this.shots) {
e.render(g2d);
}
// Turret base shadow
g2d.setComposite(this.trans);
g2d.drawImage(this.actor.getImage(1), this.pos.x-16+1, this.pos.y-16+1, null);
// Turret base
g2d.setComposite(this.solid);
g2d.drawImage(this.actor.getImage(0), this.pos.x-16, this.pos.y-16, null);
AffineTransform tx = new AffineTransform();
tx.rotate(this.rotation, 16, 16);
AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR);
// Turret shadow
g2d.setComposite(this.trans);
g2d.drawImage(op.filter(this.actor.getImage(5), null), this.pos.x-16+2, this.pos.y-16+2, null);
// Turret
g2d.setComposite(this.solid);
g2d.drawImage(op.filter(this.actor.getImage(this.towerSprite), null), this.pos.x-16, this.pos.y-16, null);
}
At this point the sprites for the tower is already scaled (and cached in my spritesheet handling thing, for easy access if need be).
EDIT:
And for the curious, here’s my “good looking” tower: http://infloop.org/tmp/tower.png
EDIT EDIT:
Cleaned the rendering code a little, now it’s around 110 towers that the fps starts to drop.