World representation - xuckz/genericProject GitHub Wiki
The world is build from blocks (boxes) of equal size. There are different types of blocks with certain parameters:
- Dirt
- Sand
- Wood
- Rock
- Water
- Clay
- ....tbc
I'm thinking about what might be the best way to represent such a world. Right now I can think of two approaches:
1) store the game world as a list of boxes with coordinates + type
e.g. : (0, 0, 0) DIRT, (0, 0, 1) SAND, ....
1.1) use one list per box type
e.g. : DIRT: (0, 0, 0), SAND: (0, 0, 1)
2) store a 3d map each entry representing a type or no box
DIRT, NIL, NIL, SAND, NIL, NIL
3) So what do we talk about? Storing the world (as a savegame) or storing the world during gameplay? And will there be a "underground"? Meaning is there only one layer of blocks or will there be a xxx deep layer of blocks? With the possibility to "shoot" "drill" whatever throuh it?
For following suggestion i suspect a savegame and with xxx deep layer of blocks:
What about storing large solid blocks of the same type in a variable array? Like storing the shape of xxx connected blocks of the same type, suggesting all blocks inside are the same type:
e.g. : DIRT BLOCKS IN THIS AREA:
(0, 0, 0)
(0, 10, 0)
(0, 10, 5)
(0, 15, 5)
(0, 0, 5)
(0, 0, 0)
I think the best attempt to store the world is the most efficient way. Storing each block would result in a massive amount of data. It will depend on how small each block will be, if 1000 blocks of one type connected together is more common then a small amount of blocks connected together, this or a similar approach would result in a less sophisticated approach storing the world.
Or am i missing something?
Of course this attempt can't be used during gameplay, or well it would make sense to differ between blocks within xxx area of the player which have the possibility to be calculated seperated, and outside a specific area, where blocks musn't be calculated.