I thought I'd share a little about how my level files have progressed from something quite inflexible to a more versatile bitmask solution
My level files used to have a "board" property that described the valence of the cells, so 1, 2, 3 or 4 like so:
"board": [
[1,2,2,1,2],
[2,1,4,2,2],
[1,2,2,4,2],
[2,2,2,2,2]
]
Then I added zero's to represent inactive cells:
"board": [
[0,2,2,1,0],
[2,1,4,2,2],
[1,2,2,4,2],
[2,0,0,0,2]
],
At which point I thought
"oh hey, this is looking really good, I should probably plan out the other cells that I need..." and that list looks something like this:
- Cells that have "sludge" behind them
- Cells that have "double-sludge" behind them
- Cells that have a "lock" over them
- Cells that contain a randomly chosen valence
- Cells that contain a "Cherry"
- Cells that are active, but empty
Of course I want to be able to combine them to say stuff like
"An active cell, with a randomly generated atom, a lock over it AND double-sludge behind"So what I've done is created a bitmask to represent the different properties:
- 0 = inactive cell
- 1 = active cell
- 2 = random valence
- 4 = valence 1
- 8 = valence 2
- 16 = valence 3
- 32 = valence 4
- 64 = cherry
- 128 = locked
- 256 = sludge
- 512 = double sludge
So to represent the above example I would have
643 made up of:
1 = An active cell
2 = Randomly generated atom
128 = A lock over
512 = Double-sludge behind
I've yet to refactor my level editor to generate these, I'm still testing them so hand-writing them suits me just fine for the time being...