Legend of the Gold Box... A game written for the LOWREZJAM 2018 game jam
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

60 lines
1.4KB

  1. from . import gbe
  2. from .nodes import *
  3. _RUNNING = False
  4. def _OnQuit(event, data):
  5. global _RUNNING
  6. _RUNNING = False
  7. def _OnVideoResize(event, data):
  8. flags = gbe.display.Display.flags
  9. gbe.display.Display.set_mode(data["size"], flags)
  10. print("Resized to {}".format(gbe.display.Display.resolution))
  11. def _OnKeyEvent(event, data):
  12. global _RUNNING
  13. if event == "KEYDOWN":
  14. if data["key"] == 27:
  15. _RUNNING = False
  16. print("Key {} down".format(data["key"]))
  17. elif event == "KEYUP":
  18. print("Key {} up".format(data["key"]))
  19. elif event == "KEYPRESSED":
  20. print("Key {} pressed".format(data["key"]))
  21. def start():
  22. global _RUNNING, _OnKeyEvent, _OnQuit, _OnVideoResize
  23. sm = gbe.statemachine.StateMachine()
  24. gbe.events.Events.listen("QUIT", _OnQuit)
  25. gbe.events.Events.listen("KEYDOWN", _OnKeyEvent)
  26. gbe.events.Events.listen("KEYUP", _OnKeyEvent)
  27. gbe.events.Events.listen("KEYPRESSED", _OnKeyEvent)
  28. d = gbe.display.Display
  29. d.init(640, 480)
  30. d.caption = "Goldbox 64"
  31. d.watch_for_resize(True)
  32. d.set_clear_color(0,0,255)
  33. root = NodeInterface()
  34. root.scale_to_display = True
  35. root.keep_aspect_ratio = True
  36. root.align_center = True
  37. root.set_surface((64, 64))
  38. sm.register_node(root)
  39. sm.activate_node(root.name)
  40. _RUNNING = True
  41. while _RUNNING:
  42. gbe.events.pollEmitter()
  43. sm.update()
  44. sm.render()
  45. sm.close()
  46. d.close()