@lozzajp wrote:
I am thinking of using a bit mask to make collision design a bit easier. Here is an example, but this could be anything say different types of enemies and only certain ones may collide and hurt the player.
[Flags] public enum BitMask { None = 0, Ground = 1, Sand = 2, Water = 4, // etc. above could be say zombie, dragon etc for damage collision. }
Is an enum the right way to go about this? I imagine say my player to have something like the following
class player { int collidables = 6; // this is represented as 0110, so can collide with ground, sand but not water, none. }
The idea then is later in collision checking I can look at all surrounding blocks and they will have their type, say ground so I can do something like:
if (block.Type | player.collidables) return true;
Does anyone have any guidance or resources to use a pattern like this?
Posts: 11
Participants: 5