Game Dev Journal

I've decided to store my game's map definitions and other customizable data in JSON format. My thoughts are as follows:

  • JSON is well-supported in C# via Json.NET (and of course built in via other subsets of .NET such as WCF if you're using those to build a program).
  • It is a familiar format and less verbose than XML, but is the simplest data format to effectively manage this game's data.
  • If I want to create a server and incorporate online functionality, the data format will already be predisposed to that function.

The map files will use a .map file extension and the contents will be base-64 encoded for some modicum of encryption. There isn't a particular reason for it other than to make it harder for common people to hack up the maps and screw up the game, but you could easily find the map code in the source (which will be on my Github account sooner or later) and figure out how to either decode the map files to edit by hand or redesign them your own way with the Map Editor.

For the time being while I flesh out the game, my map files will be simple and contain only a few elements:

  1. An ID (int) which must be unique.
  2. A readable title which describes the room or area.
  3. The map definition itself which is an array of arrays (pertaining to each row of the map, of course) holding integers corresponding to textures on the texture map.

Here's a sample JSON map file as it currently stands, but will certainly change in the near future as I work with the system more and flesh it out:

{
	"title": "Test Map",
	"id": 1,
	"map": [
		[20,20,20,20,20,20,20,20,20,20],
		[20,1,1,1,1,1,1,1,1,20],
		[20,1,5,2,2,2,2,4,1,20],
		[20,1,7,0,0,0,0,6,1,20],
		[20,1,7,0,0,0,0,6,1,20],
		[20,1,7,0,0,0,0,6,1,20],
		[20,1,7,0,0,0,0,6,1,20],
		[20,1,9,3,3,3,3,8,1,20],
		[20,1,1,1,1,1,1,1,1,20],
		[20,20,20,20,20,20,20,20,20,20]
	]
}

A here's the current texture map I'll be working with. The integers in the arrays above are the tile positions, the top left tile being indexed at 0, the next as 1, and so on. At the end of the row it simply moves down a row and keeps counting from left to right. (The 32x32 outline is just there to distinguish the tiles for display purposes.)

Game texture map

When rendered in game, that map will give me this output (minus the character who is just there for kicks):

Game level example