making a scrolling background. There is one problems with this code below.
I am drawing a image and it stay there on left of screen. i want to del it and create new one so there aren't 100's of background images on left. i just want to keep 2 background images. This way it will save some memory.

//top of class
int x = 0;
int x2 = Main.WINDOW_WIDTH;
...
//game loop
x-=2;
x2-=2;
...
//paint method
g.drawImage(Levels.getBGImage1(), x, y, width, height, null); 
g.drawImage(Levels.getBGImage1(), x2, y, width, height, null);

if(x+Main.WINDOW_WIDTH < 0){
    x = Main.WINDOW_WIDTH;
    g.drawImage(Levels.getBGImage1(), x, y, width, height, null);
}
if(x2+Main.WINDOW_WIDTH < 0)
{
    x2 = Main.WINDOW_WIDTH;
    g.drawImage(Levels.getBGImage1(), x2, y, width, height, null);
}

Edited 3 Years Ago by game06

cant belive i got caught in finding remove method online that i missed a simple solution.

Thanks alot

Edited 3 Years Ago by game06

This question has already been answered. Start a new discussion instead.