You are right. It is used to emphasise feeling or emotion. As a general rule, it is probably best to avoid using the exclamation point except in the rare occasion when the feeling or emotion is extreme. It is very easy to overuse exclamation marks, but no one will ever complain if you never use them.
In the US and Canada the exclamation mark always goes inside the quotation marks, like in the text that you cited ("Bad boy!"). They can replace periods, but don't always replace them.
In British English, I am of the understanding that exclamation marks are placed in or out of the quotation marks based on the logical relationship to the words inside the quotes. So, if the person being quoted is the one who is expressing feeling or emotion, then the exclamation mark goes in the quotes; whereas, if it is the writer who is expressing the emotion, then the exclamation mark goes outside the quote. So, for example, the writer says "I can't believe she said 'Let them eat cake'!"
I'm not sure if exclamation points can replace periods in British English (as I did in the British sample above). I'm sure someone else will be able to better clarify this.
Student or Learner