I was curious as to how you would go about converting from pixel to tile precision on a tile map. For example, let's say my map is comprised of 8x6 tiles, each of which are 50x50 pixels in size. If I could only get the current coordinates of my mouse in pixels, how would I go about finding which tile those pixels are contained in programmatically?
It's quite simple. Just divide your position with tile dimensions. Like this.
tileX = positionX / tileWidth
tileY = positionY / tileHeight
this will give you x and y tile, where your position is. This assumes that your top left tile is at 0,0 coordinates.
So, in your case, lets say coordinates are x:256,y:172
tileX = x / 50
tileY = y / 50
This would result
tileX = 5
tileY = 3