views:

74

answers:

2

I played a web game a while back called racewarkingdoms. It used a 2d text based system. What interest me is the map. The map is made up of 255 tiles in X direction, and 255 in Y direction. There are 5 of these maps total. But what is amazing is that each one contains so much data. Each one contains its own 'kingdom' which would be about 50 variables per tile. Then each one contains 'monsters' with health bars and data that is remembered permanetly.

How would something like this be designed. I doubt each tile was a table. I would assume you would have a map1_table with the different elements that would be found in any, but I am just not sure. I am approaching a situation where I need a similar design, but don't know where to start.

Thanks!

+3  A: 

First I would start by defining a map like this,

MAPS
Id  
Name  
Xmax  
Ymax

Here you can define the map by giving it a name and the maximum dimensions. You could use the max dimensions to constraint the tiles.

TILES
Id
MapId
X
Y

Then construct a tiles properties table to hold all properties associated with a tile.

TILEPROPERTIES
Id
TileId
Name
Value

This would be my implementation and doesn't mean it should work for you, but it hopefully gets you started.

madC
Good idea ;), very "small" but it contains the most important structures
daemonfire300
+1  A: 

Click here for scheme file

I would recommend to use the following structure combined with my scheme:

  • tiles saves the amount of tiles in general, each tile has ONE id, the size of a tile is hard-coded: 5*5 px for example.

  • tiles_meta saves the name, and a short "tooltip" description. META is self-explainary ;)

  • tiles_content_low contains a minority of the the tile. Here you should include the things a user will access many times, but keep it minimal.

  • tiles_content_medium contains such things as "here item xy can be found with a chance of 12%". Create an addition "loot_table" with items. The "item_hash" is a hash of all item ids of the items which may drop.

  • tiles_content_large is the biggest table. Here you store on which coordinate inside of the tile the player is located, where he looted item number 1234 etc.

table: tiles
id

table: tiles_meta
id
tile_id
name
desc

table: tiles_content_low
id
tile_id
owner_id
go_id

table: tiles_content_medium
id
tile_id
mob_hash
item_hash

table: tiles_content_large
id
tile_id
savegame

If you want to build a tile_set or "map" use JavaScript, do not generate a whole map on your server, just pass the tile date to the JavaScript. This will save much performance.

daemonfire300
Very good information. Graphics are not a huge focus as it is pretty much text based, on a non scrolling map. But still very good... I would have never thought about it from this viewpoint.