Does dreams affect your mood when you wake up?

Usually when I'm having a bad dream my mood when I wake up gets affected...what happens is I usually wake up with a grumpy mood when I just had a bad dream..or I get the feeling like my whole body is in pain..there are also times when I just had a great dream,my mood for the whole day is also great and I feel so happy..
Why is this so??does dreams really affect the mood of a person?