Legend of the Gold Box... A game written for the LOWREZJAM 2018 game jam
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

68 lines
1.7KB

  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. text = gbe.nodes.NodeText("TextNode", root)
  39. text.font_src = "IttyBitty.ttf"
  40. text.size = 4
  41. text.antialias = False
  42. text.text = "ObsidianBlk 123456"
  43. text.set_color(255, 64, 128)
  44. text.position_y = 30
  45. sm.register_node(root)
  46. sm.activate_node(root.name)
  47. _RUNNING = True
  48. while _RUNNING:
  49. gbe.events.pollEmitter()
  50. sm.update()
  51. sm.render()
  52. sm.close()
  53. d.close()