Hello i'm making a game for my object oriented programming class , i have a world with a scroll based on a project named "Scrolling Man" . that´s the code for the scroll :
public void scroll(int cX, int cY)
{
x = x +cX;
y = y +cY;
getBackground().drawImage(Background,x, y);
}
the method is called when an arrow is pressed and it works, but i have a problem. the method makes very slow my game, i tried to reduce the size of the background but that no solves the problem, i removed the method call, and the game have not more lag.
Please help me, how can i make the scroll without lag???