Hi I have a java game and when I increase the xoffset and yoffset the fps goes down hugely , in the top left corner(xoffset = 0; y offset = 0;) 450 fps , in the bottom right corner I get 19 fps.
Here is the code for my rendering and my world tick();
public void render() {
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
core.pixmap[x + (y * width)] = image[x + core.xoffset][y
+ core.yoffset];
}
}
}
This is what draws it to the pixmap;
public void render() {
BufferStrategy bs = getBufferStrategy();
if (bs == null) {
createBufferStrategy(2);
return;
}
screen.clear();
screen.render();
Graphics g = bs.getDrawGraphics();
g.drawImage(pixmapimg, 0, 0, width, height, null);
g.dispose();
bs.show();
}
handles the image drawing(in a seperate class)
for (int x = -32 + core.xoffset / 32; x < (core.width + core.xoffset + 100) / 32; x++) {
for (int y = -32 + core.yoffset / 32; y < (core.height
+ core.yoffset + 100) / 32; y++) {
if (x >= 0 && x < (core.width * 3) / 32 && y >= 0
&& y < (core.height * 3) / 32) {
core.screen.draw(x * 32, y * 32, map[x][y].getgraphics());
map[x][y].tick();
}
}
}
and the world.tick();