Android touch event force closes
<p>I have a 2d array displaying on the screen and decided to implement a method where it would detect the touch location and find the tile in which the touch is located and remove it, r more precisely, change the int at map[x][y].
I currently have a 2d map array full of 3s 15 by 15.
Touch a location and this method, which i created because I could not find a way to round down numbers, would calculate the position in the array and change the value:</p>

<pre><code>public boolean onTouchEvent(MotionEvent event) {

    mX = (int) event.getX();
    mY = (int) event.getY();
    calculate();
    return true;
}

public void calculate() {

    indexX = 0;
    indexY = 0;
    for (int n = 32; n &lt; mX; n += 32) {
        indexX++;
    }
    for (int n = 32; n &lt; mY; n += 32) {
        indexY++;
    }
    map[indexY][indexX] = 1;
}
</code></pre>

<p>It'll force close if I starting mashing the screen or dragging my finger around, but if I touch a single location one by one slowly it works fine.
I assumed the method to calculate should not be in the touch event method but still am not quite sure.</p>
