23
« on: June 17, 2013, 06:53:27 pm »
There are several reasons it is wrong.
1. I could be wrong on this one, but iirc, until you've finished processing events for the frame, the Keyboard and Mouse buffers won't be up to date. If you want the sf::Keyboard and sf::Mouse functions to give you up to data data, you must call them after the event loop.
2. When your game is running, there may be frames where more than one event is processed. If multiple events are processed, your sprite will move multiple times in that frame when it should only move once. Conversely, if no events occur in a frame (which is usually more likely than multiple events in a frame), then your sprite won't move at all when it should.