This week I wanted to figure out why my ships weren’t flying like in SC2 and I found it
Got rid of a couple bugs in my code and now the physics are ALOT better, much more SC2-like. I spent a couple days trying to figure out this one procedure from the original SC2 code:
void SetVelocityComponents (VELOCITYPTR velocityptr, SIZE dx, SIZE dy)
{
 COUNT angle;
 if ((angle = ARCTAN (dx, dy)) == FULL_CIRCLE)
 {
  ZeroVelocityComponents (velocityptr);
 }
 else
 {
  if (dx >= 0)
  {
   velocityptr->vector.width = VELOCITY_TO_WORLD (dx);
   velocityptr->incr.width = MAKE_WORD ((BYTE)1, (BYTE)0);
  }
  else
  {
   dx = -dx;
   velocityptr->vector.width = -VELOCITY_TO_WORLD (dx);
   velocityptr->incr.width =
     MAKE_WORD ((BYTE)0xFF, (BYTE)(VELOCITY_REMAINDER (dx) << 1));
  }
  if (dy >= 0)
  {
   velocityptr->vector.height = VELOCITY_TO_WORLD (dy);
   velocityptr->incr.height = MAKE_WORD ((BYTE)1, (BYTE)0);
  }
  else
  {
   dy = -dy;
   velocityptr->vector.height = -VELOCITY_TO_WORLD (dy);
   velocityptr->incr.height =
     MAKE_WORD ((BYTE)0xFF, (BYTE)(VELOCITY_REMAINDER (dy) << 1));
  }
  velocityptr->fract.width = VELOCITY_REMAINDER (dx);
  velocityptr->fract.height = VELOCITY_REMAINDER (dy);
  velocityptr->error.width = velocityptr->error.height = 0;
 }
 velocityptr->TravelAngle = angle;
}
I just can’t wrap my head around what the fract, incr, and error variables are used for. Man, all that bitshifting confuses me, and I see it in the code EVERYWHERE :O :O Thankfully, my own code seems to get the job done.
So now that the ships seem pretty good, i think i can move onto some projectiles? Wow, i guess the ships will be able to do more than fly and crash.  Amazing :)Â