When a key is pressed, if it is held down, it takes a bit for it to continue registering. I'm pretty sure there's a way around this, but I can't figure it out.
Also, how can I handle multiple key inputs at the same time? If say, I'm holding the Right key down, then press space, the Right key is no longer being held down (and I have to press it again).
while (App.IsOpened())
{
sf::Event Event;
const sf::Input &Input = App.GetInput();
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
App.Close();
if (Input.IsKeyDown(sf::Key::Left))
Game.player->Move("Left");
else if (Input.IsKeyDown(sf::Key::Right))
Game.player->Move("Right");
if (Event.Type == sf::Event::KeyPressed)
{
if (Event.Key.Code == sf::Key::Escape)
App.Close();
else if (Event.Key.Code == sf::Key::Space)
Game.pl_lasers.push_back(Game.player->FireLaser());
}
}
About the Input.IsKeyDown() being mixed up with the Event.Type checking, I think I remember reading something about Input being better for some reason.. tbh, I don't remember why I used it.
Thanks for help!