FreeEntity.bb 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ; FreeEntity Example
  2. ; This example creates an entity and
  3. ; allows you to move it, but shows
  4. ; that a handle is no longer valid after
  5. ; FreeEntity is used on it.
  6. ; Run in Debug Mode
  7. Graphics3D 640,480
  8. AppTitle "FreeEntity Example"
  9. Cam = CreateCamera()
  10. Lit = CreateLight()
  11. PositionEntity Lit,-5,-5,0
  12. PositionEntity Cam,0,0,-5
  13. AnEntity = CreateCube() ; This is our Test Entity
  14. RotateMesh AnEntity,45,45,45
  15. While Not KeyDown(1) ; Until we press ESC
  16. ; Use the Left or Right Arrows to Move the Entity
  17. If KeyDown(203) Then MoveEntity AnEntity,-0.1,0,0
  18. If KeyDown(205) Then MoveEntity AnEntity,0.1,0,0
  19. ; Use the Space Key to Free the Entity. It will disappear
  20. ; The next time you try to move it, you will get an error
  21. ; Notice that the Handle Variable doesn't change after the
  22. ; Entity is free. It simply becomes invalid.
  23. If KeyHit(57) Then FreeEntity AnEntity ; Hit Space to Free!
  24. RenderWorld ; Draw the Scene
  25. ; What is in the AnEntity handle?
  26. Text 10,10,"Entity Handle: "+AnEntity
  27. Flip ; Flip it into View
  28. Wend
  29. End