Bläddra i källkod

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

master
Bryan Miller 6 år sedan
förälder
incheckning
6c2deddfca
1 ändrade filer med 23 tillägg och 2 borttagningar
  1. +23
    -2
      game/__init__.py

+ 23
- 2
game/__init__.py Visa fil

@@ -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()

Laddar…
Avbryt
Spara