question: public static int XToTileX ( int x , int tileGridXOffset , int tileWidth ) { x -= tileGridXOffset ; if ( x < 0 ) { x += 1 - tileWidth ; } return x / tileWidth ; }
target:  Converts a pixel's X coordinate into a horizontal tile index relative to a given tile grid layout specified by its X offset and tile width.