Created
April 2, 2011 00:08
-
-
Save zaphire/899084 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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