MoveEntity.bb 1009 B

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