Where Hamlet is dark and depressed by his father's death, Ophelia goes beyond grief into madness and then suicide when she learns that not only has her father been killed, but he met his end at the hands of Hamlet, her former boyfriend.
When we first meet Hamlet, in Act 1, Scene 2, he is despondent about his father's death and not just a little put off by his mother's hasty marriage to her dead husband's brother. Here is Hamlet's state of grief in his own words:
'tis not alone my inky cloak, good mother,
Nor customary suits of solemn black,
Nor windy suspiration of forced breath,
No, nor the fruitful river in the eye,
Nor the dejected havior of the visage,
Together with all forms, modes, shapes of grief,
That can denote me truly. These indeed seem,
For they are actions that a man might play;
But I have that within which passeth show,
These but the trappings and the suits of woe.
In other words, he wants everyone to know, especially his mother, how much he loved his father and how very sad he is about his death.
After her father's murder, Ophelia completely loses her wits. But this is only part of the equation. With their father slain, Ophelia and her brother Laertes are a split reverse mirror image of Hamlet.
Hamlet's father was killed, and the Ghost tells him by whom and how he has to get revenge, but Hamlet doesn't strait-away do what he was told to do. Rather, he does a lot of thinking and planning and acts a bit crazy, which is part of methodical plan to finally get to the King. So, Hamlet is slow to revenge and only playing at being nuts.
Laertes, on the other hand, when he finds out about his father's murder, is all about getting revenge as soon as possible. No planning and play-acting for him. And as for Ophelia, the other reverse mirror image of Hamlet, she can no longer think straight, begins to babble, sing and talk nonsense, and eventually drowns herself in her grief. Laertes, thus, is quick to revenge and Ophelia goes completely nuts.