Hey!
So, I've managed to get together a blob that moves around the screen with the WASD keys, by this code:
const sf::Input& Input = Win.GetInput();
bool LeftKeyDown = Input.IsKeyDown(sf::Key::A);
bool RightKeyDown = Input.IsKeyDown(sf::Key::D);
bool UpKeyDown = Input.IsKeyDown(sf::Key::W);
bool DownKeyDown = Input.IsKeyDown(sf::Key::S);
And then later down the switch (Event.Type) this:
(Head is the sprite I want to control movement with)
case sf::Event::KeyPressed:
if (UpKeyDown)
Head.Move(0, -10);
if (DownKeyDown)
Head.Move(0, 10);
if (RightKeyDown)
Head.Move(10, 0);
if (LeftKeyDown)
Head.Move(-10, 0);
Now, this works to a degree, using the sf::Input i can press up and right at the same time and it'll go diagonal. (Whereas i just had KeyPressed before)
However, upon pressing for example W (to go up) it moves one step (10 pixels) then stops for about half a second, then continues relatively smooth.
I guess I should use the clock somehow and decrease the Move to maybe 1 pixel per 0.1 seconds or something, so that I can get the smooth movement I want.
Just not sure how to go about this, any ideas?
Also, sorry if this is in the wrong section.