This animation shows the motion of molecules in a gas enclosed in a cylinder. As the piston is moved in the number of collisions with the walls increases and so the pressure of the gas increases. We are assuming that there is no loss of energy on collision and so the temperature of the gas stays constant.