Which of these two level method should I use? :P

Sorry for the bad title, I’ll try and explain more :stuck_out_tongue:

You see, I’m currently creating a overview 2D type of game, and in that game I’m going to have a big city overview map for the players to roam around in (think GTA and Zelda type). :slight_smile: The problem is that I’m very uncertain on how I should do this. I know a lot of people make tiles and use arrays to make maps in 2D overview games, but since I’m going to create a large map, with alot of free space like streets, I was wondering if it would be better to just make a big background and then use the arraylist method to draw important objects, like building and trashcans, on top of the background again :stuck_out_tongue:

What do you think? :slight_smile:

Always go for the most simple method.

Big background images usually take up a lot of RAM. So you have to be careful that you don’t use up all your memory when you load the entire map at once. Depending on the size, it will be the easiest solution, but it’ll also take a lot of memory to render it all.

Tile maps are a bit better because you can control how much of the map you show at once. Since people will not search up everywhere on a map at once, you can load the map in smaller chunks. IT will save memory and make your game faster depending on the technology used (Java2D, LWJGL, JOGL, etc.)

I personally like using the second method. because not everyone searches every square pixel of a map you create. However, you see the pros and cons of each method here, so it should give you some better insight.

Okay, I see :slight_smile: I’m planning to port the game to android later :stuck_out_tongue: Do you think that would be a problem with rendering a big background then? :stuck_out_tongue: I know that andorid devices have less RAM than PCs :confused:

Yep, it can be a big issue on Android. Don’t quote me, but on current Android devices you are limited to between 24 and 32MB heap memory, but older devices have as little as 16MB to play with. If you exceed this your app will bail out with an ‘out of memory’ exception. Large images will chew this up quickly.

If Android is you ultimate aim, then you should probably be looking towards the tile-map approach and re-using textures wherever possible; or at least only loading the segments that you immediately need.

Doesn’t Android handle it’s “Bitmap memory” (as in images) aside from the rest of your apps memory? Also on android 4.0+ you can request more memory and if you did your file loading in ndk then you can use a lot more memory (you are limited by available memory rather than allocated memory).
Anyway, you can always load sections of the image one at a time and load them into the gl texture as needed.

Yeah, thats a good idea :slight_smile: I’ll have the game load up parts of the images which is required :stuck_out_tongue:

I’m really not looking forward to learning how to make the map since I’m bad at graphics and stuff like that xD Do any of you guys know a good tutorial on how to code maps in to java games? :slight_smile:

In general no, they still come out of your allocated memory and hence count towards your memory limit. Although apparently they don’t when using OpenGL like you’ve suggested.

A bit of Googling or Youtubing should give you some idea. There is a few ‘map design/format’ topics on this forum too. I can’t for the life of me think of any good tutorials on it, my apologies.
Edit: And if you do go have a search, don’t necessarily limit yourself to ‘coding maps in java games’. The general principles are the same for any language.

Okay, thanks for all the answers :smiley:

Okay, so I found this thing called Tiled Map Editor which seems really nice! :slight_smile: All I’m wondering about is if anybody out there have used this before and if I can use it with just pure java for my game? :slight_smile:

Java

A library for loading TMX files is included with Tiled at util/java/libtiled-java.
libgdx, a Java-based Android/desktop/HTML5 game library, provides a packer, loader and renderer for TMX maps

Does that help ?

No need to pack your .tmx maps with libgdx anymore…http://www.badlogicgames.com/wordpress/?p=2870