To get the good ending, level your village up to its maximum level. Then, complete the game to get the crown and the good ending.
To get the bad ending do not advance your village all the way. Then, complete the game to get the bad ending and the pistol.