Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I'm using this code to load a tiled map, composed of 1000x1000 32x32px tiles:

map = new TmxMapLoader().load("levels/xyz.tmx");

camera = new OrthographicCamera();

camera.setToOrtho(false, Constants.WORLD_WINDOW_SIZE.x / 32,
            Constants.WORLD_WINDOW_SIZE.y / 32);

renderer = new OrthogonalTiledMapRenderer(map, 1 / 32f);



And this code for rendering:


However, I have huge performance issues. How can I optimize this code ? Will splitting the map in multiple submaps help?

Greetings, TM3P

share|improve this question

marked as duplicate by Byte56, Sean Middleditch, bummzack, Trevor Powell, Tetrad Mar 12 '13 at 20:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

You should consider rendering only the visible tiles/objects. related:…… – petervaz Mar 11 '13 at 15:40
Thanks for your responses and sorry for duplicate – UberLambda Mar 11 '13 at 15:56
up vote 3 down vote accepted

In addition to the techniques discussed in the link above, think about frame layering as well. In my game engine (board is 750 x 450 hexes of 32^2 pixels) I triple buffer the display into map, units, and highlights. On each Paint cycle:

  • MapBuffer is repainted only if the view has panned or zoomed;
  • UnitBuffer is refreshed from MapBuffer and units repainted only if one or more units has moved;
  • HighlightBuffer is refreshed from UnitBuffer and repainted; and
  • HighightBuffer is drawn to screen.
share|improve this answer
Thanks, that's a technique I've never thought of. I'll code something similar some day – UberLambda Mar 11 '13 at 18:19
I was initially intimidated when I realized it was necessary - but it turned out to be quite straightforward. P.S.: The best and most appreciated thank you is a vote. – Pieter Geerkens Mar 11 '13 at 18:23
I'm sorry but i can't vote up, nor down :| – UberLambda Mar 11 '13 at 20:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.