Skip to content

Instantly share code, notes, and snippets.

@zaphire
Created April 2, 2011 00:08
Show Gist options
  • Save zaphire/899084 to your computer and use it in GitHub Desktop.
Save zaphire/899084 to your computer and use it in GitHub Desktop.
// fall, cap at maxFallSpeed
velocity.y += MIN(gravity * Monocle::deltaTime, maxFallSpeed);
position += velocity * Monocle::deltaTime;
float useSpeed = isWalking?walkSpeed:runSpeed;
const float turnThresh = 0.25f;
if (moveDir.x > turnThresh)
scale.x = 1;
else if (moveDir.x < -turnThresh)
scale.x = -1;
if (fabs(moveDir.x) < 0.5f)
{
moveDir.x = 0;
}
position += moveDir * useSpeed * Monocle::deltaTime;
int y = 0;
int max = 16;
for (y = 0; y < max; y++)
{
CollisionData collisionData;
if (Collide("Obstruction", &collisionData))
{
position.y = lastPosition.y;
velocity.y = 0;
}
else
{
break;
}
position.y = lastPosition.y - y;
}
if (y == max)
{
position = lastPosition;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment