What's the best way to compare blocks in a matching game that can be multiple colors?
Posted
by
Ryan Detzel
on Game Development
See other posts from Game Development
or by Ryan Detzel
Published on 2013-08-03T10:47:38Z
Indexed on
2013/11/02
10:16 UTC
Read the original article
Hit count: 265
logic
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?
© Game Development or respective owner