Created
April 2, 2011 23:28
-
-
Save NoelFB/900007 to your computer and use it in GitHub Desktop.
Movement Code
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
// 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