Legend of the Gold Box... A game written for the LOWREZJAM 2018 game jam
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

61 lines
1.6KB

  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. t = gbe.time.Time()
  24. t.reset()
  25. resources = gbe.resource.ResourceManager()
  26. gbe.events.Events.listen("QUIT", _OnQuit)
  27. gbe.events.Events.listen("KEYDOWN", _OnKeyEvent)
  28. gbe.events.Events.listen("KEYUP", _OnKeyEvent)
  29. gbe.events.Events.listen("KEYPRESSED", _OnKeyEvent)
  30. d = gbe.display.Display
  31. d.init(640, 480)
  32. d.caption = "Goldbox 64"
  33. d.watch_for_resize(True)
  34. #gbe.events.Events.listen("VIDEORESIZE", _OnVideoResize)
  35. root = NodeInterface()
  36. root.scale_to_display = True
  37. root.keep_aspect_ratio = True
  38. root.align_center = True
  39. root.set_surface((64, 64))
  40. _RUNNING = True
  41. while _RUNNING:
  42. gbe.events.pollEmitter()
  43. d.surface.fill(pygame.Color(0,0,255))
  44. #pygame.draw.rect(d.surface, pygame.Color(255,0,0), (0,0,20,10), 1)
  45. root._update(t.delta)
  46. root._render(d.surface)
  47. d.flip()
  48. d.close()