Hi, just wanted to test performance of drawing a tile as a single image versus cutting the tile from a larger image:
Method 1, single 32*32 image
for(int i = 0; i < 30; i++)
for(int j = 0; j < 20; j++)
{
g.drawImage(img, i*32, j*32, this);
g.setColor(Color.red);
g.fillRect(0, 0, 200, 50);
g.setColor(Color.green);
g.drawString("FPS: " + fps, 20, 20);
}
Method 2: 3232 fragment of 512512 image
for(int i = 0; i < 30; i++)
for(int j = 0; j < 20; j++)
{
g.drawImage(img, i*32, j*32, i*32 + 32, j*32 + 32, 0, 0, 32, 32,this);
g.setColor(Color.red);
g.fillRect(0, 0, 200, 50);
g.setColor(Color.green);
g.drawString("FPS: " + fps, 20, 20);
}
Conclusion: NO difference at all, I’m a happy camper:)
btw: I think I remember there is a name for this often used method?