Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from direct.showbase.ShowBase import ShowBase
- from direct.task import Task
- class Game(ShowBase):
- def __init__(self):
- super().__init__()
- self.keys = {
- "a": False,
- }
- self.accept("a", self.key_down, ["a"])
- self.accept("a-up", self.key_up, ["a"])
- taskMgr.add(self.check_key_state, "check_key_state")
- def key_down(self, key):
- self.keys[key] = True
- def key_up(self, key):
- self.keys[key] = False
- def check_key_state(self, task):
- if self.keys["a"]:
- print("Key 'a' is held down")
- else:
- print("Key 'a' is not held down")
- return Task.cont
- game = Game()
- game.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement