Use mousePressed(), the function, instead. Because with the variable, if you click over several frames (60 per second! so it is likely...), you end in an unknown state...
BTW, i = 0; i++; is the same that i = 1;...
BTW, i = 0; i++; is the same that i = 1;...