Make the arrow keys work too.

master
Zed A. Shaw 8 months ago
parent 38c0fee65c
commit 084a9c59a6
  1. 10
      sfmldemo/main.cpp

@ -126,13 +126,11 @@ int main() {
break;
case sf::Event::KeyPressed:
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {
shape.move(-20, 0);
b2Vec2 force(-200, 1000);
box.body->ApplyForceToCenter(force, true);
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) {
shape.move(20, 0);
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) {
shape.move(0, -20);
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) {
shape.move(0, 20);
b2Vec2 force(200, 1000);
box.body->ApplyForceToCenter(force, true);
}
break;
case sf::Event::MouseButtonPressed:

Loading…
Cancel
Save