TranslateEntity.bb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. ; TranslateEntity Example
  2. ; -----------------------
  3. Graphics3D 640,480
  4. SetBuffer BackBuffer()
  5. camera=CreateCamera()
  6. light=CreateLight()
  7. cone=CreateCone( 32 )
  8. ; Rotate cone by random amount to demonstrate that TranslateEntity is independent of entity orientation
  9. RotateEntity cone,Rnd( 0,360 ),Rnd( 0,360 ),Rnd( 0,360 )
  10. ; Translate cone in front of camera, so we can see it to begin with
  11. TranslateEntity cone,0,0,10
  12. While Not KeyDown( 1 )
  13. ; Reset translation values - otherwise, the cone will not stop!
  14. x#=0
  15. y#=0
  16. z#=0
  17. ; Change translation values depending on the key pressed
  18. If KeyDown( 203 )=True Then x#=-0.1
  19. If KeyDown( 205 )=True Then x#=0.1
  20. If KeyDown( 208 )=True Then y#=-0.1
  21. If KeyDown( 200 )=True Then y#=0.1
  22. If KeyDown( 44 )=True Then z#=-0.1
  23. If KeyDown( 30 )=True Then z#=0.1
  24. ; Translate sphere using translation values
  25. TranslateEntity cone,x#,y#,z#
  26. ; If spacebar pressed then rotate cone by random amount
  27. If KeyHit( 57 )=True Then RotateEntity cone,Rnd( 0,360 ),Rnd( 0,360 ),Rnd( 0,360 )
  28. RenderWorld
  29. Text 0,0,"Use cursor/A/Z keys to translate cone, spacebar to rotate cone by random amount"
  30. Text 0,20,"X Translation: "+x#
  31. Text 0,40,"Y Translation: "+y#
  32. Text 0,60,"Z Translation: "+z#
  33. Flip
  34. Wend
  35. End