Flying Flappy Bird with arrow keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""fly() and dip() functions are called whenever the up arrow key is pressed or released respectively.""" | |
def key_press(self, key): | |
"""Listen for key press.""" | |
if key == Key.up: | |
self.fly() | |
return False | |
def key_release(self, _): | |
"""Listen for key release.""" | |
self.dip() | |
return False | |
def keyboard_update(self, _): | |
"""ROS Timer Callback Keyboard Listener for a press and release.""" | |
with keyboard.Listener(on_press=self.key_press) as listener_for_key_press: | |
listener_for_key_press.join() | |
with keyboard.Listener(on_release=self.key_release) as listener_for_key_release: | |
listener_for_key_release.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment