Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am interested in developing games for the Android OS. I have played Replica Island and I have browsed over the source. I found that the levels/maps were in a .bin format. I could execute them because they were in an Android format. So how could I make a game map/level that could be used in my game? What program would I use? How could I load the map in Java (for Android)?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

I think you're missing it a bit here. What happens is that your game or app is run, and that then opens and reads in the data from a map file. The map file is not actually executable, it simply holds data.

Say you have a tile map of 10x10 in a 2d array. Say that it is all water (tile ID 0) and grass (tile ID 1). You would save this into a file, row by row, probably in a binary (not human readable) format. So if your map had a few rows like this:

0001011101
0010111101
0001011101
0010111101
0001011101
0010111101
0001011101
0010111101
0001011101
0010111101

(It's repeating, but it's an example. All the 0s are water and 1s are land)

You would go through each row and save it to a file. So your file would just be, in binary:

0001011101001011110100010111010010111101000101110100101111010001011101001011110100010110010111101

When you come to read it in, you would read in number by number, and you know that a 0 is water (and you would set that tile to be water) and the 1 to be land.

Of course, this is very simple. But the chance is you would have an ID system, so rather than saving 'water water land' you can do '001'. Same for items - instead of 'sword, location 1,0; axe, location 3,0' you would maybe write yours in binary as '45 1 0 76 3 0'.

For Java, look up any kind of file API documentation.

share|improve this answer

Usually, you make a map like lets say a 2D array, and then output it in whatever format. Binary is small and fast, so you might want to use that. You would then have a reader in your game which would parse through that file (binary or whatever) and load your "level" data structure accordingly.

share|improve this answer
    
How would I create a binary file to hold that byte data (I'm running Linux/Windows)? Would I have each byte represent a specific kind of tile such as a wall, sprite? Could you please give me an example of what that 2D array would look like? (Sorry, I'm new to game development) –  Mohit Deshpande Feb 2 '11 at 19:21
    
See TheCommunistDuck's reply. It should give you an idea of what the 2D array would look like. The idea is..imagine your world to be segmented into tiles (each of dimension 32 x 32pixels). This would look like a grid (or 2D array). Now, you can assign int ids to each cell and the array would look like his reply. So, now your game knows wheres land and wheres water. Now, once you author this 2d array, you can serialize it and store in binary format. When your game loads this file, it would deserialize it and reconstruct that 2D array, which your game can now interpret based on the ids stored –  brainydexter Feb 2 '11 at 19:41
    
Look at serialization/deserialization for storing your data in a binary file. –  brainydexter Feb 2 '11 at 19:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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