{ int prevX = tailX [0]; int prevY = tailY [0]; int prev2X, prev2Y; tailX[0] = x; tailY[0] = y; for(int i = 1;i < nTail ; i++) { prev2X = tailX[i]; prev2Y = tailY[i]; tailX[i] = prevX; tailY[i] = prevY; prevX = prev2X; prevY = prev2Y ; } switch (dir) { case LEFT: x--; break; case RIGHT: x++; break; case UP: y--; break; case DOWN: y++; break; default: break; }