Not a great title but couldnt think of a shorter way to describe it.
I am trying to think of the best way to determine the shape of items placed in the players inventory. I guess the best examples to explain would be something like the Horadric Cube in Diablo 2 or I suppose also, the Workbench in Minecraft. There are others, I just can't remember them.
Currently the best way I can think of involves multiplying the cell numbers each item is in. This way I can look at the product of that multiplication and know from a short list of values, what shape the items are in.
My inventory is ordered like so:
1 | 2 | 3 4 | 5 | 6 7 | 8 | 9
I would also have various arrays of preset values like:
FourSquares - 40, 180, ..., ... VLines - 28, 80, ... HLines - 6, 120, ... Backslash - 45 Forwardslash - 105
So, say the user places items in 1, 2, 4 and 5 - That would give 40 and I could loop through each shape array and determine that it matched a value in the FourSquares array and go from there.
Does this seem like the best way to do it? Is there maybe a way that I wouldnt have to loop through the arrays? Would this be possible with bitwise operations maybe?