ClearCollisions.bb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ; ClearCollisions Example
  2. ; -----------------------
  3. Graphics3D 640,480
  4. SetBuffer BackBuffer()
  5. camera=CreateCamera()
  6. light=CreateLight()
  7. sphere=CreateSphere( 32 )
  8. PositionEntity sphere,-2,0,5
  9. cone=CreateCone( 32 )
  10. EntityType cone,type_cone
  11. PositionEntity cone,2,0,5
  12. ; Set collision type values
  13. type_sphere=1
  14. type_cone=2
  15. ; Set up sphere collision data
  16. EntityRadius sphere,1
  17. EntityType sphere,type_sphere
  18. ; Set up cone collision data
  19. EntityType cone,type_cone
  20. ; Enable collisions between type_sphere and type_cone, with sphere->polygon method and slide response
  21. Collisions type_sphere,type_cone,2,2
  22. While Not KeyDown( 1 )
  23. x#=0
  24. y#=0
  25. z#=0
  26. If KeyDown( 203 )=True Then x#=-0.1
  27. If KeyDown( 205 )=True Then x#=0.1
  28. If KeyDown( 208 )=True Then y#=-0.1
  29. If KeyDown( 200 )=True Then y#=0.1
  30. If KeyDown( 44 )=True Then z#=-0.1
  31. If KeyDown( 30 )=True Then z#=0.1
  32. MoveEntity sphere,x#,y#,z#
  33. ; If spacebar pressed then clear collisions
  34. If KeyHit( 57 )=True Then ClearCollisions
  35. ; Perform collision checking
  36. UpdateWorld
  37. RenderWorld
  38. Text 0,0,"Use cursor/A/Z keys to move sphere"
  39. Text 0,20,"Press spacebar to use ClearCollisions command"
  40. Flip
  41. Wend
  42. End