Geographic compass

i need help on developing a compass for my map. the compass is to follow the mouse wherever the mouse goes . i can code the mouse follows but i need help on the compass .the compass direction shd shake around when the mouse is moved ,when the mouse stops(settles),the compass should show the original direction of NEWS …i.e north …