Hello.
Im looking in to the article on the frontpage http://www.gamedev.net/page/resources/_/technical/game-programming/implementing-component-entity-systems-r3382 about component entity systems..
bitwise operations have never been my strong suit,
I am looking at this line here
if((world->mask[entity] & MOVEMENT_MASK) == MOVEMENT_MASK)
in this part
#define MOVEMENT_MASK (COMPONENT_DISPLACEMENT | COMPONENT_VELOCITY)
void movementFunction(World *world)
{
unsigned int entity;
Displacement *d;
Velocity *v;
for(entity = 0; entity < ENTITY_COUNT; ++entity)
{
if((world->mask[entity] & MOVEMENT_MASK) == MOVEMENT_MASK)
{
d = &(world->displacement[entity]);
v = &(world->velocity[entity]);
v->y -= 0.98f;
d->x += v->x;
d->y += v->y;
}
}
}
and cant figure out why this is needed.
if((world->mask[entity] & MOVEMENT_MASK) == MOVEMENT_MASK)
couldn't you just put it like this ->
if(world->mask[entity] == MOVEMENT_MASK)
I hope you can help clarify this for me
Best Regards
Morten