I often need such a function, for example, to understand the direction of touches on the iPhone and the only way to solve this problem using logic, for example:
int dir,distY;
distY = newY-oldY;
if (distY > 0)
{
dir = 1;
}
else if (distY < 0)
{
dir = -1;
}
I would like to know if there is a way to do this in one of mybey games using the math method or the old school way.
Clarification, a similar example of what I'm looking for:
i = ++i % max;
instead:
i++;
if ( i > max ) { i = 0; }
source
share