Save yourself sometimes and use % instead.
nebRunningTime += dt;
if (nebRunningTime >= nebUpdateTime)
{
nebRec.x = ((nebFrame % 60)%8) * nebRec.width;
nebRec.y = ((nebFrame % 60)/8) * nebRec.height;
nebRunningTime = 0.0;
nebFrame++;
}
also, nebFrame
is an int
and int
has a max number which is 2147483647
, so to calculate when we will reach that number:
let’s say we run the animation at 60 fps
1 second = 60 frames
so
2147483647 / 60 = 35,791,394 seconds
or
2147483647 / 60 ** 2= 596,523 minutes
or
2147483647 / 60 ** 3 = 9,942 Hours
or
2147483647 / (60 ** 3) * 24 = 414 Days
Pretty long play hours, but even so, we can use this nebFrame = nebFrame%60
after incrementing the nebFrame
to always keep the frames within 60.
Note: I just found out we can’t use %
operation for floats.