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.

54 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.align_center = True
  34. root.set_surface((64, 64))
  35. _RUNNING = True
  36. while _RUNNING:
  37. gbe.events.pollEmitter()
  38. d.surface.fill(pygame.Color(0,0,255))
  39. #pygame.draw.rect(d.surface, pygame.Color(255,0,0), (0,0,20,10), 1)
  40. root._update(t.delta)
  41. root._render(d.surface)
  42. d.flip()
  43. d.close()