static void buzztrack_preprocess (PELEMENT ElementPtr) { if (ElementPtr->thrust_wait) --ElementPtr->thrust_wait; else { COUNT facing = 0; if (ElementPtr->hTarget == 0 && TrackShip (ElementPtr, &facing) < 0) { ZeroVelocityComponents (&ElementPtr->velocity); } else { #define ACTIVATE_RANGE 224 /* Originally SPACE_WIDTH */ SIZE delta_x, delta_y; ELEMENTPTR eptr; LockElement (ElementPtr->hTarget, &eptr); delta_x = eptr->current.location.x - ElementPtr->current.location.x; delta_y = eptr->current.location.y - ElementPtr->current.location.y; UnlockElement (ElementPtr->hTarget); delta_x = WRAP_DELTA_X (delta_x); delta_y = WRAP_DELTA_Y (delta_y); facing = NORMALIZE_FACING ( ANGLE_TO_FACING (ARCTAN (delta_x, delta_y)) ); if (delta_x < 0) delta_x = -delta_x; if (delta_y < 0) delta_y = -delta_y; delta_x = WORLD_TO_DISPLAY (delta_x); delta_y = WORLD_TO_DISPLAY (delta_y); if (delta_x >= ACTIVATE_RANGE || delta_y >= ACTIVATE_RANGE || (DWORD)((UWORD)delta_x * delta_x) + (DWORD)((UWORD)delta_y * delta_y) >= (DWORD)ACTIVATE_RANGE * ACTIVATE_RANGE) { ZeroVelocityComponents (&ElementPtr->velocity); } else { ElementPtr->thrust_wait = TRACK_WAIT; SetVelocityVector (&ElementPtr->velocity, DISPLAY_TO_WORLD (2), facing); } } } spin_preprocess (ElementPtr); }
static void decelerate_preprocess (ELEMENT *ElementPtr) { SIZE dx, dy; GetCurrentVelocityComponents (&ElementPtr->velocity, &dx, &dy); dx /= 2; dy /= 2; SetVelocityComponents (&ElementPtr->velocity, dx, dy); if (dx == 0 && dy == 0) { ElementPtr->preprocess_func = buzztrack_preprocess; } spin_preprocess (ElementPtr); }