/* Updates the thing, especialy it's spite state direction and animation. */ void thing_update(Thing * self, double dt) { /* Update the things layer if uit has no support under hit's feet and it's level is greater than 1 and it's flying. */ if ((thing_z(self) > 1) && (self->hull)) { if(!bumphull_support(self->hull)) { /* No support, drop down. */ thing_z_(self, 1); } } if(!flags_get(self->flags, THING_FLAGS_LOCK_DIRECTION)) { int newdir; BeVec vel = thing_v(self); double magnitude = bevec_length(vel); if (fabs(magnitude) > 0.00) { /* could change dir if moving. TODO: take the old direction into account for more control of facing when moving diagonally. */ if (vel.x < -0.01) { newdir = SPRITE_WEST; } else if (vel.x > 0.01) { newdir = SPRITE_EAST; } else if (vel.y < -0.01) { newdir = SPRITE_NORTH; } else if (vel.y > 0.01) { newdir = SPRITE_SOUTH; } else { /* Not much motion, don't change dir */ newdir = thing_direction(self); } /* Change direction. spritestate_pose will see if nothing changed and do nothing. in that case */ thing_poseifold_(self, SPRITE_STAND, SPRITE_WALK); thing_direction_(self, newdir); } else { thing_poseifold_(self, SPRITE_WALK, SPRITE_STAND); /* This won't work on attacking, etc. */ } } else { LOG("Thing direction locked!"); } spritestate_update(&self->spritestate, dt); }
/** Checks if an individual flag is set */ int bbwidget_flag_p(BBWidget * self, int flag) { return flags_get(self->flags, flag); }
/** Checks if an individual flag is set. */ int camera_flag(Camera * self, int flag) { return flags_get(self->flags, flag); }
/** Checks if an individual flag is set. */ int thing_flag(Thing * self, int flag) { return flags_get(self->flags, flag); }