3
votes

I am developing a game using libgdx. Now i'd like to have a Background all over my map (Map size is not fixed yet i'll decide later). My map is tile based but i don't use TiledMaps. So i create and load the map with own code/editor.

My question now: How should i implement the background thing?

I thought about different ways:

  • Loading a huge Image, which covers all the map. This is not realy good cause i render things, which are not in my viewport (80 Tiles X,50 Tiles Y).

  • Deviding the Image in 4 or more Images and loading the one in the viewport. The Problem: At some point maybe part of all Images is in viewport so all Images are sent to GPU right?

  • Having 1 Image which cover the viewport (80,50) and follows the camera. Best performance i think, but it will look stupid...

  • Or every tile has an own Image and the Objects are drawn above them. Notice that i only render Tiles inside the viewport. But on Gamestart it would need to load Information about every tile in the level.

For Information: My Game is Topdown and the Background Shows the floor so no detailed hills etc are needed, just maybe some simple desert sand look and things like that. Is there another even better way?

What would be the best way for performance and optic?

1
just a performance thing i notice. Why do you render objects that are not in viewport? You lose alot of performance. Just update the obj outside of the viewport dont render them.BennX
I don't render tiles outside the viewport but when a part of an Image is in viewport i thought the whole Image would be rendered. Is it wrong?Springrbua
nono thats right. But just were wondering because you wrote that you render things which are not in your viewport.BennX
Only with the first an second Point, because there the Images are part in viewport part not. So for the other 2 Solutions i wouldn't render things not in the viewport.Springrbua

1 Answers

5
votes

If your game is Tile Based. It would make much more sense to have the background tiled aswell. Just use another layer for it. If your editor/loader does not support multiple layers, then I would recommend you to switch to another one, or add those features to it (if possible).

The Background Shows the floor so no detailed hills etc are needed, just maybe some simple desert sand look and things like that.

It is very easy to reuse tiles in something like a desert, because all their tiles are very similar (sand).