Bladeren bron

Added directional keys as WASD aliases and added an using to make the code cleaner

Eiyeron Fulmincendii 10 jaren geleden
bovenliggende
commit
814e1b24a6
1 gewijzigde bestanden met toevoegingen van 7 en 6 verwijderingen
  1. 7 6
      platform/sfml/Input.cpp

+ 7 - 6
platform/sfml/Input.cpp

@@ -3,33 +3,34 @@
 #include <SFML/Window/Keyboard.hpp>
 
 #define INPUT WalrusRPG::Input
+using sf::Keyboard;
 
 bool INPUT::key_a()
 {
-    return window.hasFocus() && sf::Keyboard::isKeyPressed(sf::Keyboard::Return);
+    return window.hasFocus() && Keyboard::isKeyPressed(Keyboard::Return);
 }
 
 bool INPUT::key_b()
 {
-    return window.hasFocus() && sf::Keyboard::isKeyPressed(sf::Keyboard::BackSpace);
+    return window.hasFocus() && Keyboard::isKeyPressed(Keyboard::BackSpace);
 }
 
 bool INPUT::key_up()
 {
-    return window.hasFocus() && sf::Keyboard::isKeyPressed(sf::Keyboard::W);
+    return window.hasFocus() && (Keyboard::isKeyPressed(Keyboard::W) || Keyboard::isKeyPressed(Keyboard::Up));
 }
 
 bool INPUT::key_down()
 {
-    return window.hasFocus() && sf::Keyboard::isKeyPressed(sf::Keyboard::S);
+    return window.hasFocus() && (Keyboard::isKeyPressed(Keyboard::S) || Keyboard::isKeyPressed(Keyboard::Down));
 }
 
 bool INPUT::key_left()
 {
-    return window.hasFocus() && sf::Keyboard::isKeyPressed(sf::Keyboard::A);
+    return window.hasFocus() && (Keyboard::isKeyPressed(Keyboard::A) || Keyboard::isKeyPressed(Keyboard::Left));
 }
 
 bool INPUT::key_right()
 {
-    return window.hasFocus() && sf::Keyboard::isKeyPressed(sf::Keyboard::D);
+    return window.hasFocus() && (Keyboard::isKeyPressed(Keyboard::D) || Keyboard::isKeyPressed(Keyboard::Right));
 }