Kaynağa Gözat

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

master
Bryan Miller 6 yıl önce
ebeveyn
işleme
6c2deddfca
1 değiştirilmiş dosya ile 23 ekleme ve 2 silme
  1. +23
    -2
      game/__init__.py

+ 23
- 2
game/__init__.py Dosyayı Görüntüle

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

Yükleniyor…
İptal
Kaydet