Skip to content

Instantly share code, notes, and snippets.

@API-Beast
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save API-Beast/634e78f5d408f3387b83 to your computer and use it in GitHub Desktop.
Save API-Beast/634e78f5d408f3387b83 to your computer and use it in GitHub Desktop.
obj->Speed += obj->Acceleration * dt;
obj->Speed -= obj->Speed * (AirDrag * obj->Drag * dt) * obj->Speed.getLength();
// Add gravity
for(GravitySource& src : GravitySources)
src.influence(obj, dt);
obj->Rotation += obj->RotationSpeed * dt;
Angle targetRotation = obj->Speed.getAngle();
int sign = 1;
if(targetRotation < obj->Rotation)
sign = -1;
if((targetRotation - obj->Rotation) > 0.05f)
obj->Rotation += sign * (1 - obj->Speed.normalized().dot(obj->Rotation.toDirection())) * obj->Flow * obj->Speed.getLength() / 100 * dt;
obj->RotationSpeed -= (AirDrag * obj->Drag * dt) * obj->RotationSpeed;
obj->Position += obj->Speed * dt;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment