Graphics translate method not working

Hi,
I know that are other post almost the same title, but by what I’ve read, it doesn’t is the same.
I am creating a game engine with Java2D, and it is working, except for the camera movement.
My game engine is very “flexible”, since programmers that doesn’t like my own rendering procedures can create their own. But, if I make camera movement a task of the rendering procedure, what if the programmer writing the procedure forgets to implement the camera? The solution that I found is translating each renderable object, drawing them and returning to their original position, but with this the rotation get very crappy (rotation pivot starts changing). So, my other solution was to define a offset to my Graphics2D instance, that is pass to every renderable object when drawing them, but here is the problem.
Basically, when I use Graphics2D.translate(int, int), it doesn’t change rendering base point and blocks screen clearing.

Here is the offscreen rendering:


public void render(List<RenderObject> objects) {
	clearScreen();
	g.translate(camera.getX(), camera.getY());
	for(RenderObject ro : objects) {
		ro.setRenderer(this);
		ro.draw(); // Runs renderable object own rendering procedure
	}
}

After around a second that the game is started, the clearScreen() method starts to fail, and old frames start to stack at screen. And the translate method doesn’t change origin rendering point.

What am I doing wrong? What are other solutions to this problem? Should I make camera movement a task for the rendering procedure?

translate permanently changes the translation in the graphics instance. It will accumulate every frame if you’re using the same graphics instance every time.

Cas :slight_smile: