test1.nim 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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.background_color = Color(1, 0.6, 1) # window background color.
  19. env.delay = 1000 div 120 # 120 frames per second.
  20. env.brightness = 0.0
  21. env.resizable = true
  22. env.bordered = true
  23. env.screen_mode = SCREEN_MODE_EXPANDED
  24. test "Setup window":
  25. build: # Node builder
  26. - Scene main # Create an empty Scene node with the name "main".
  27. test "Register events":
  28. addKeyAction("forward", "w")
  29. addKeyAction("backward", "s")
  30. test "Handle events":
  31. main@onProcess(self):
  32. if isActionJustPressed("forward"):
  33. echo "forward pressed!"
  34. elif isActionJustPressed("backward"):
  35. echo "backward pressed!"
  36. addMainScene(main) # Adds scene to window and
  37. windowLaunch()