As a school project I am creating a browser game in Java, for the Google App Engine platform. Its a strategy game of players fighting with each other on a tile-based board.
I want the match and board structure to be dynamic. The board size is different for each match (selected when the match is created), players may join or leave in the middle of the match, each board tile may contain multiple different objects (players’ pawns, tile bonuses etc) and the objects may be moved between the tiles.
The problem is that I’m new to Java and I’m not sure how to represent and store such multi-level, dynamic structure.
1) Conceptually it looks like a “2D array of lists of objects”, but how should it be defined in terms of Java language? Is it a “List of Lists of Lists of objects” or “2D-Array of Lists of objects” or maybe even something else?
2) What part of that structure should be stored in the Datastore (GAE’s object-oriented database) and which should be built dynamically when the board is displayed to the player?
The more I store the easier it will be to display the board, but on the other hand it will be more painful to update when the objects move.
I suggest you to store it as list of independent map entries, with 2d coordinate.
Something like:
and, by querying all map elements, by query like
select MapEntry where map = ?(depends on what database mapping tool you’re using) you can get all map details, and build it in memory in server or client side. And i’m sure that for most cases you don’t need to load whole map into memory.