An X-ray machine is basically just a camera. Where a camera uses visible light, however, an X-ray machine uses X-rays to expose the film.
X-rays, like light, are electromagnetic waves. But X-rays are more energetic so they can - to varying degrees - penetrate many materials. When the X-rays hit film, they expose it just as light would. Bone, fat, muscle, tumors and other types of masses all absorb X-rays at different levels. The image on the film, therefore, lets doctors see different (distinct) structures inside the body.