test1.nim 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # --- Test 1. Work with Window.. --- #
  2. import
  3. nodesnim,
  4. unittest
  5. suite "Work with Window":
  6. test "Create window":
  7. # Window(title, width, height)
  8. Window(title = "MyWindow",
  9. w = 720, h = 480)
  10. test "Change Window title":
  11. setTitle("My own window ^^")
  12. test "Change Window icon":
  13. setIcon("assets/sharp.jpg")
  14. test "Resize and centered window":
  15. resizeWindow(1024, 640)
  16. centeredWindow()
  17. test "Setup environment":
  18. env.color = Color(1, 0.6, 1) # window background color.
  19. env.delay = 1000 div 120 # 120 frames per second.
  20. test "Setup window":
  21. build: # Node builder
  22. - Scene main # Create an empty Scene node with the name "main".
  23. test "Register events":
  24. addKeyAction("forward", "w")
  25. addKeyAction("backward", "s")
  26. test "Handle events":
  27. main@onProcess(self):
  28. if isActionJustPressed("forward"):
  29. echo "forward pressed!"
  30. elif isActionJustPressed("backward"):
  31. echo "backward pressed!"
  32. addMainScene(main) # Adds scene to window and
  33. windowLaunch()