We propose the energy efficient MAC algorithm in this paper. In the proposed algorithm, each node sets the contention window size with respect to the residual energy, the harvesting energy and the transmit power. This algorithm makes the sensor nodes consume their energy efficiently. To achieve this goal, we use the game theory and the cross-layer optimization. Introducing the non-cooperative game, we can formulate the utility function easily. In this paper, we can allocate the optimal power by the cross-layer optimization on the PHY and the MAC.