If you already know the number of frames (which you should, considering you made the animation) you can just use the number of degrees.
- Code: Select all
animpos = angle / 45;
This only uses one division, so is more efficient.
Even better, you can do a multiplacation - take the angle - in this case 45 - and divide 1 by it. 1 / 45 = 0.022222222222222222222222222222222
That would be
- Code: Select all
animpos = angle * 0.022222222222222222222222222222222;
This is not quite such a nice number for it, so you may want to divide anyway. But when it becomes a nice compact number, such as .1 or .025 or whatever, you can multiply.