31
Window / Re: two keyboard keys pressed at the same time?
« on: July 23, 2017, 12:39:15 pm »
well...using event for it can be tough but I think it can be done...I'll try to experiment on it
in the mean time
in the mean time
while (window.isOpen())
{
sf::Event eventCheck;
while (window.pollEvent(eventCheck))
{
if (event.type == sf::Event::Closed) window.close();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))
{
sprite.move(0, -5);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::A))
{
sprite.move(-5, 0);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::S))
{
sprite.move(0, 5);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::D))
{
sprite.move(5, 0);
}
window.clear();
window.draw(sprite);
window.display();
}
return 0;
{
sf::Event eventCheck;
while (window.pollEvent(eventCheck))
{
if (event.type == sf::Event::Closed) window.close();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))
{
sprite.move(0, -5);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::A))
{
sprite.move(-5, 0);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::S))
{
sprite.move(0, 5);
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::D))
{
sprite.move(5, 0);
}
window.clear();
window.draw(sprite);
window.display();
}
return 0;