What's the best way to compare blocks in a matching game that can be multiple colors?
- by Ryan Detzel
I have a match 3-4 game and the blocks can be one of 7 colors. There are an addition 7 blocks that are a mix of the original 7 colors so for example there is a red and blue block and there is also a red/blue block which can be matched with either the red or the blue. My original thought is just to use binary operations so.
int red = 0x000000001;
int blue = 0x000000010;
int redblue = 0x000000011;
Then just do an & operation so see if they match. Does this sound like a decent plan or am I over complicating it?
edit:
Better yet so it's more readable.
int red = 1;
int blue = 2;
int red_blue = 3;
int yellow = 4;
int red_yellow = 5;
maybe as defines or static vars?