The ideas given there are quite good, but there is something bothering me. Please, let's not fall once again in potential endianess problems using raw binary data, though.
Plus, I forgot, but we'll have
to store the tile fullness, which can be either 0, 25, 50, 75 , or 100. (%)
In any case, I'd like to keep having the simple array solution, since it would make things much easier to debug, for everyone.
There are three solutions I'd see so far, from the most preferred to the least. Thanks for all the ideas about it, btw.
1. Use Nido's idea about having string-based tile value. (My favourite one so far, thanks Nido.). Eg:
The first digit is the team number ownership (0 for none).
The letter gives the tile type:
L: Lava
W: Water
D: Dirt
T: Temple
...
the second digit gives the fullness:
0: 0% (ground tile. I'd suggest to use 0 for rooms or maybe we could use this as a HP value?)
1: 25%
2: 50%
3: 75%
4: 100%
We'd have this, for instance:
- {l Code}: {l Select All Code}
<!-- The map -->
<map sizeX="10" sizeY="10">
0D4,0D4,0D4,0D4,0D4,0D4,0D4,0D4,0D4,0D4
0D4,0L4,0D0,0D0,0D4,0D0,1T0,1T0,1T0,0D4
0D4,0L4,0D0,0D0,0D4,0D0,1T0,1T0,1T0,0D4
0D4,0D0,0C4,0C4,0D4,0D4,1T0,1T0,1T0,0D4
0D4,0D4,0D4,0D4,0D4,0D4,0D0,0D0,0D0,0D4
0D4,0D4,0D4,0D4,0D4,0D4,0D0,0D0,0D0,0D4
0D4,0W4,0D0,0D0,0D4,0D0,0D0,0D0,0D0,0D4
0D4,0W4,0D0,0D0,0D4,0D0,0D0,0D0,0D0,0D4
0D4,0D0,0W3,0W3,0D4,0D0,0D0,0D0,0D0,0D4
0D4,0D4,0D4,0D4,0D4,0D4,0D4,0D4,0D4,0D4
</map>
2. an hybrid solution based on the binary approach keeping the array:
I'd propose to use bitmask values that we would merge and save as ints. Eg:
// Rooms/tiles bitmask values
int32 EMPTY = 0;
int32 DIRT = 1;
int32 ROCK = 2;
int32 CASTLE = 4;
int32 WATER = 8;
int32 LAVA = 16;
int32 TEMPLE = 32;
...
// Fullness
int32 ZERO = 0;
int32 25_ = 128;
int32 50_ = 256;
int32 75_ = 512;
int32 100_ = 1024;
// ownership bitmasks
int32 NO_OWNERSHIP = 0;
int32 PLAYER_1 = 2048;
int32 PLAYER_2 = 4096;
...
example of saved value:
int32 tileValue = CASTLE | PLAYER_1 | 100_;
- {l Code}: {l Select All Code}
<!-- The map -->
<map sizeX="10" sizeY="10">
1025,1025,1025,1025,1025,1025,1025,1025,1025,1025
1025,1026,0,0,1025,2080,2080,2080,0,1025
1025,1026,0,0,1025,2080,2080,2080,0,1025
1025,0,1027,1027,1025,1025,2080,2080,2080,1025
1025,1025,1025,1025,1025,1025,0,0,0,1025
1025,1025,1025,1025,1025,1025,0,0,0,1025
1025,1026,0,0,1025,0,0,0,0,1025
1025,1026,0,0,1025,0,0,0,0,1025
1025,0,1027,1027,1025,0,0,0,0,1025
1025,1025,1025,1025,1025,1025,1025,1025,1025,1025
</map>
I'm not sure about this one, though, especially when we add more room/tiles/traps.
3. Store the tile/room/trap id, the ownership, and the fullness in separate 'layers'. This means we wouldn't have one array, but three.
(The less optimized solution, and not really readable, unfortunately.)
What do you think?
Best regards,