Your modulo value should be 12, not 11. Modulo returns the remainder of the division (More precisely the equation of m % n
is m - floor(m/n)n
), so 11 / 11 will indeed return 0.
However, with 12, 11 / 12 will be 11, 12 / 12 is 0 and 13 / 12 have 1 as the remainder. It 'wraps around' your value - 1
So you should use this instead :
i = (gameTime.TotalGameTime.Milliseconds / n) % 12
Examples with 12:
var b = 10 % 12; //10
var c = 11 % 12; //11
var d = 12 % 12; //0
var e = 13 % 12; //1