Perturbatio #1 If you are drawing your tile palette at 0,0 for instance you can simply divide the mouse coordinates by the width and height respectively to find the array index.