I am making a game that uses 50*50 pixels(rpg) where a character walks around(so far). He needs to be able to shoot at things, based on the range of his rifle. I have determined how to make a line travel from him to the enemy. But, I need to determine the range at what it is.

i.e.
if it travels up 4 x's, and 4 y squares, then the range should be 4.
if it travles across 4 x's, and 0 y's, then the range is 4.
if it travels up 3 x's, and 2 y's, then the range should be 3.

anybody have any help?