I am making 2D blocks game, everything is ok, but i cant make water falling correct. Water falling is working, but it takes too much FPS.
My water blocks extends class Blocks. To render blocks i am using VBOs (one chunk - one VBO). Right now i am updating chunk VBO, when water block moves. I am doing it like that:
for(int cx = 0;cx < sizex;cx++){
for(int cy = 0;cy < sizey;cy++){
for(int bx = 0;bx < 16;bx++){
for(int by = 0;by < 16;by++){
if(cy == sizex-1 && by == 15){
}else{
if(chunks[cx][cy].blocks[bx][by].isWater){
if(by == 15){
if(chunks[cx][cy+1].blocks[bx][0].id == IDS.airBlockID){
chunks[cx][cy+1].blocks[bx][0] = new WaterBlock(...);
chunks[cx][cy].blocks[bx][by] = new AirBlock(...);
chunks[cx][cy].updateVBOTextures();
chunks[cx][cy+1].updateVBOTextures();
}
}else{
if(chunks[cx][cy].blocks[bx][by+1].id == IDS.airBlockID){
chunks[cx][cy].blocks[bx][by+1] = new WaterBlock(...);
chunks[cx][cy].blocks[bx][by] = new AirBlock(...);
chunks[cx][cy].updateVBOTextures();
}
}
}
}
}
}
}
}
My main FPS problem here is this line:
chunks[...][...].updateVBOTextures();
I am updating VBOs every tick, and it takes too much FPS. I want to ask, how i can avoid this VBOs updating every tick, and still get similar result (i want to see how water falling).