Преглед на файлове

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

master
Bryan Miller преди 6 години
родител
ревизия
6c2deddfca
променени са 1 файла, в които са добавени 23 реда и са изтрити 2 реда
  1. +23
    -2
      game/__init__.py

+ 23
- 2
game/__init__.py Целия файл

@@ -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…
Отказ
Запис