test30.nim 811 B

123456789101112131415161718192021222324252627282930313233
  1. # --- Test 30. use CollisionShape2D. --- #
  2. # Please, compile with `--define:debug` or with `-d:debug` for see collision shapes.
  3. import nodesnim
  4. Window("hello world")
  5. var
  6. main = Scene("Main")
  7. shape1 = CollisionShape2D()
  8. shape2 = CollisionShape2D()
  9. shape3 = CollisionShape2D()
  10. shape1.move(100, 100)
  11. shape2.move(125, 125)
  12. shape3.move(170, 125)
  13. shape3.setShapeTypeCircle(0, 0, 35) # by default shape type is a rect, but you can change it at any time.
  14. shape2.disable = true # by default shape enabled, but you can change it at any time.
  15. echo shape1.isCollide(shape2) # if one of two shapes is disabled - return false.
  16. echo shape1.isCollide(shape3)
  17. echo shape2.isCollide(shape3)
  18. main.addChild(shape1)
  19. main.addChild(shape2)
  20. main.addChild(shape3)
  21. addScene(main)
  22. setMainScene("Main")
  23. windowLaunch()