Here is a particular example of a heat engine - the Otto cycle, which approximates the working cycle of a car engine. The work done is the area enclosed by the curve in the plane. The expansion and compression stokes are adiabatic, so heat enters and leaves only during the constant volume phases. (This ignores the exhaust stroke, which can be modelled as a horizontal line from point 1 left and then right again.)
This link, courtesy of Xing Min Wang, has clear and helpful animations of the idealised Otto, Diesel and Carnot cycles.
Animated Engines has animations of a large variety of realistic engines, though without the accompanying cycles.
The efficiency of a reversible Otto cycle for an ideal gas is
Try to prove it yourself. More details are given here. You should also convince yourself that the efficiency is less than that of a Carnot engine acting between the reservoirs at the hottest and coldest ponts of the cycle.