CopyEntity.bb 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ; CopyEntity Example
  2. ; This example creates an entity and
  3. ; allows you to make copies of it.
  4. Graphics3D 640,480
  5. AppTitle "CopyEntity Example"
  6. Cam = CreateCamera()
  7. Lit = CreateLight()
  8. PositionEntity Lit,-5,-5,0
  9. PositionEntity Cam,0,0,-5
  10. AnEntity = CreateCube() ; This is our Test Entity
  11. ScaleMesh anEntity,0.4,0.4,0.4
  12. While Not KeyDown(1) ; Until we press ESC
  13. If KeyHit(57) Then
  14. ; When we hit Space, a new Entity is created
  15. ; These share the same internal mesh structure though!
  16. ; Hence although we are only Rotating the original MESH
  17. ; Linked to the original Entity, since it is a Mesh command,
  18. ; all the Entity Copies are linked to it..
  19. NewEntity = CopyEntity(AnEntity) ; Hit Space to Copy!
  20. ; Change the Color of the Entity. Since this is an entity
  21. ; Property, it doesn't effect the other copies.
  22. EntityColor NewEntity,Rand(255),Rand(255),Rand(255)
  23. PositionEntity NewEntity,Rand(4)-2,Rand(4)-2,0
  24. EndIf
  25. SeedRnd MilliSecs()
  26. RotateMesh AnEntity,.25,.35,.45
  27. RenderWorld ; Draw the Scene
  28. Flip ; Flip it into View
  29. Wend
  30. End