Steam locomotives require a fire to burn in a firebox, which is surrounded by a chamber filled with water. Pipes lead from the firebox into the water-filled chamber, carrying the hot gases used to heat the water.
When the water in the locomotive boils it produces steam that rises to the top of the chamber and collects in a dome. From the dome, the steam is passed through a series of pipes to the engine's cylinders, where the amount of steam is regulated as it passes into the engine's valves.
As steam expands in an attempt to return to its normal pressure, it is pushed through pistons that move in a back-and-forth motion. This motion is used to turn wheels in steam locomotive trains through a series of rods that connect the pistons to the wheels.