Creating the first type of character seems easy enough: just throw lots of adversity at them, and have them triumph over it. (The word "seems" may be doing a lot of heavy lifting, there...)
Creating the latter? Entire volumes have been written about that; I can't really do the topic justice here. 2/2