Legend of the Gold Box... A game written for the LOWREZJAM 2018 game jam
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4KB

  1. from . import gbe
  2. from .nodes import *
  3. _RUNNING = False
  4. def _OnVideoResize(event, data):
  5. flags = gbe.display.Display.flags
  6. gbe.display.Display.set_mode(data["size"], flags)
  7. print("Resized to {}".format(gbe.display.Display.resolution))
  8. def _OnKeyEvent(event, data):
  9. global _RUNNING
  10. if event == "KEYDOWN":
  11. if data["key"] == 27:
  12. _RUNNING = False
  13. print("Key {} down".format(data["key"]))
  14. elif event == "KEYUP":
  15. print("Key {} up".format(data["key"]))
  16. elif event == "KEYPRESSED":
  17. print("Key {} pressed".format(data["key"]))
  18. def start():
  19. global _RUNNING, _OnKeyEvent, _OnVideoResize
  20. t = gbe.time.Time()
  21. t.reset()
  22. gbe.events.Events.listen("KEYDOWN", _OnKeyEvent)
  23. gbe.events.Events.listen("KEYUP", _OnKeyEvent)
  24. gbe.events.Events.listen("KEYPRESSED", _OnKeyEvent)
  25. d = gbe.display.Display
  26. d.init()
  27. d.caption = "Goldbox 64"
  28. d.watch_for_resize(True)
  29. #gbe.events.Events.listen("VIDEORESIZE", _OnVideoResize)
  30. root = NodeInterface()
  31. root.scale_to_display = True
  32. root.keep_aspect_ratio = True
  33. root.set_surface((64, 64))
  34. _RUNNING = True
  35. while _RUNNING:
  36. gbe.events.pollEmitter()
  37. d.surface.fill(pygame.Color(0,0,255))
  38. #pygame.draw.rect(d.surface, pygame.Color(255,0,0), (0,0,20,10), 1)
  39. root._update(t.delta)
  40. root._render(d.surface)
  41. d.flip()
  42. d.close()