Skip to content

Instantly share code, notes, and snippets.

@NoelFB
Created April 2, 2011 23:28
Show Gist options
  • Save NoelFB/900007 to your computer and use it in GitHub Desktop.
Save NoelFB/900007 to your computer and use it in GitHub Desktop.
Movement Code
// move
lastPosition = position;
position += velocity * Monocle::deltaTime;
CollisionData col;
if(Collide("Solid", &col))
{
// move to last position
// 64 is the radius of the player collider
position.y = col.hitPoint.y + (col.normal.y * 64);
// no longer falling
velocity.y = 0;
// hit a wall?
if(abs(col.normal.y) < 0.5f) velocity.x = 0;
// now on ground
OnGround(true);
}
else
{
OnGround(false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment