About g2d drawing and program efficiency.

Here is the case.

I have a map that is 10 times the size of the screen. So only part of the map can be seen at time. And question is,

which would be better if I draw this map?

  1. translate Graphics2D to a proper focus, then draw the whole map.
  2. find out which part of the map should be shown, and draw only that part.

I am not sure if approach 1 would be much slower.

(In an other word, I don’t know if drawing out of the Clip consumes calculation)

Only draw tiles that are within the screen coordinates.

the short answer is, yes draw only the parts that appear on screen.

When I started out making a 2d game I had a map that was the size of the screen so I drew it all (32x32 tiles). then I made the map bigger (64x64 tiles), and then over time I added the ability to scroll around then made the map even bigger (128x128).

Then my frame rate went right down and it took me ages to figure out that I was drawing the entire map every single frame!

So basically, the sooner you work out which tiles will be on screen and only draw those tiles, the easier it will be to make the maps bigger in the future :slight_smile: