In my android application of NetWalk, I've got a grid to display and randomise images based on NetWalk.
However, everytime I touch one of the cells to rotate, the whole grid randomises again.
Any idea how I would go about fixing this?
That's the main bit of code to randomise the grid:
for (int col = 0; col < mGame.getColumns(); col++)
{
for(int row = 0; row < mGame.getRows(); row++)
{
int randomNumber = rand.nextInt(3);
for (int turns = 1; turns < randomNumber; turns++)
{
mGame.rotateRight(col, row);
}
This handles the touch input:
@Override
public void onLongPress(MotionEvent ev)
{
float x = ev.getX();
float y = ev.getY();
int touchedColumn = (int) x / (int) sqWidth;
int touchedRow = (int) y / (int) sqHeight;
mGame.rotateRight(touchedColumn, touchedRow);
invalidate();
}
Aucun commentaire:
Enregistrer un commentaire