Last active
December 11, 2015 03:38
-
-
Save mharju/4538988 to your computer and use it in GitHub Desktop.
what the....
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
double direction_x = 0.0, direction_y = 0.0, direction = 0.0; | |
CGPoint d = CGPointMake(current.x - previous.x, current.y - previous.y); | |
if(d.x != 0) { | |
if(current.y <= kCenterY) { | |
if(d.x > 0.0) { | |
direction_x = 1.0; | |
} else { | |
direction_x = -1.0; | |
} | |
} else { | |
if(d.x > 0.0) { | |
direction_x = -1.0; | |
} else { | |
direction_x = 1.0; | |
} | |
} | |
} | |
if(d.y != 0) { | |
if(current.x <= kCenterX) { | |
if(d.y > 0.0) { | |
direction_y = -1.0; | |
} else { | |
direction_y = 1.0; | |
} | |
} else { | |
if(d.y > 0.0) { | |
direction_y = 1.0; | |
} else { | |
direction_y = -1.0; | |
} | |
} | |
} | |
direction = abs(current.y - kCenterY) > abs(current.x - kCenterX) ? direction_x : direction_y; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment