Browse Source

Changed to utilize the Events class and pollEmitter function. Program will currently quit after pressing ESCAPE.

master
Bryan Miller 6 years ago
parent
commit
6c2deddfca
1 changed files with 23 additions and 2 deletions
  1. +23
    -2
      game/__init__.py

+ 23
- 2
game/__init__.py View File

@@ -1,11 +1,32 @@
import game.gbe

_RUNNING = False


def onKeyEvent(event, data):
global _RUNNING
if event == "KEYDOWN":
if data["key"] == 27:
_RUNNING = False
print("Key {} down".format(data["key"]))
elif event == "KEYUP":
print("Key {} up".format(data["key"]))
elif event == "KEYPRESSED":
print("Key {} pressed".format(data["key"]))



def start():
global _RUNNING, onKeyEvent
t = game.gbe.Time()
t.reset()

game.gbe.events.Events.listen("KEYDOWN", onKeyEvent)
game.gbe.events.Events.listen("KEYUP", onKeyEvent)
game.gbe.events.Events.listen("KEYPRESSED", onKeyEvent)
d = game.gbe.Display()
d.init()
while t.aliveSeconds < 5.0:
print(t.aliveSeconds)
_RUNNING = True
while _RUNNING:
game.gbe.events.pollEmitter()
d.close()

Loading…
Cancel
Save