As resources have alternative uses, the quantity supplied of a commodity depends not only on its price, but also on the prices of other commodities. Increase in the prices of substitute goods makes them more profitable in comparison to the given commodity. As a result, the firm shifts its limited resources from production of the given commodity to production of other goods, e.g. increase in the price of wheat will induce the farmer to use land for cultivation of wheat in place of rice.
Decrease in price of substitute good will shift the supply curve to the right and vice-versa.
In case of complementary goods, if price of one good increases, then supply of its complementary good also increases, conveying a direct relationship. So, rise in the price of car, will cause the supply of petrol to also rise and the supply curve shifts to the rightward ad vice-versa.