You have your mouse handling code in an else statement. That means that for every single event type other than keydown (ie: window close, key up, window resize, etc, etc), you will be running your mouse handling code.
You have to look specifically for mouse events.. and only have your mouse handling code when a mouse event happens.
thanks for the reply. but omitting else won't help. i think i'm not calculating previous mouse position and current mouse position right. any suggestions for that please?
Errr.... are you just deleting the else? Or are you replacing it with a check for mouse events?
You need to be doing the latter.
EDIT:
To clarify further:
1 2 3 4
if(fEvent.type == sf::Event::KeyPressed) // <- this is how you check if an event is a Key Pressed event
if(fEvent.type == sf::Event::MouseMoved) // <- this is how you check to see if an event
// is a mouse moved event
You are never doing that 2nd check. Instead you are doing this:
if(sf::Event::MouseMoved)
Which is always going to be true because that value is nonzero.