开发者

browser game map storage and implementation

I'm writing a simple browser based game with a 2d tile map. I'm implementing this map as an HTML table (ok, you can yell at me for using tables later, but it works) with background images. The map could be very very large, but it won't change much, if at all. I could eventually make more maps though.

The map cells will not only have a background image, but properties like what's on them, items or special events, town entrances, etc. I'd like to ask what might be the best way to store this data. I'm leaning against a database because of how unchanging the map would be. Only things on top of the cells would be in the database. But how should I store the background then? As huge PHP arrays that get loaded in piec开发者_JAVA百科es?

Any additional tips on beginning such a system, things that I can't yet anticipate, would be greatly appreciated.


Flat files are a better choice than databases for tile-based maps. If you can fix the maximum number of objects that can be present on a tile - for pre-defined objects, this could just be a bitmask - then each tile will require a fixed amount of storage and you can then just lay out your map as a flat sequence of tiles. You can index to any tile (x,y) in this representation by seeking to the y * map_width + x-th position.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜