Advertisement
Guest User

Blitz3D code sample

a guest
Jun 26th, 2015
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Graphics3D 640,480
  2.  
  3. SetBuffer BackBuffer()
  4.  
  5. SeedRnd MilliSecs()
  6.  
  7.  
  8. ; create camera
  9. camera=CreateCamera()
  10. CameraClsColor camera,160,160,160
  11. PositionEntity camera,0,0,-30
  12. middle=CreatePivot()
  13. EntityParent camera,middle
  14.  
  15. ; create add texture - white cirlce on a black background
  16. For n=0 To 50
  17. Color 5+(n*5),5+(n*5),5+(n*5)
  18. Oval 10+n,10+n,236-(n*2),236-(n*2),1
  19. Next
  20.  
  21. blob_tex=CreateTexture(256,256)
  22. blob=CreateImage(256,256)
  23. GrabImage blob,0,0
  24. CopyRect 0,0,256,256,0,0,ImageBuffer(blob),TextureBuffer(blob_tex)
  25. FreeImage blob
  26.  
  27. max_blobs=100
  28.  
  29. ; create blobs using add blend mode
  30. Dim blobs(max_blobs) ; blob sprites
  31. Dim xyblobs#(max_blobs,2) ; blob vector
  32.  
  33. For n=0 To max_blobs
  34.     blobs(n)=CreateSprite()
  35.     EntityFX blobs(n),1
  36.     EntityBlend blobs(n),3 ;set blend mode to add
  37.     EntityTexture blobs(n),blob_tex
  38.     xyblobs(n,0)=Rnd(-.1,.1)
  39.     xyblobs(n,1)=Rnd(-.1,.1)
  40.     xyblobs(n,2)=Rnd(-.1,.1)
  41.     EntityColor blobs(n),Rand(0,255),Rand(0,255),Rand(0,255) ;give it a colour
  42.     Next
  43.  
  44. ; create cube texture
  45. Color 255,255,255
  46. Rect 0,0,256,256,1
  47. For n=0 To 7
  48.     If n=0 Then Color 0,0,0
  49.     If n=1 Then Color 0,0,255
  50.     If n=2 Then Color 0,255,0
  51.     If n=3 Then Color 0,255,255
  52.     If n=4 Then Color 255,0,0
  53.     If n=5 Then Color 255,0,255
  54.     If n=6 Then Color 255,255,0
  55.     If n=7 Then Color 255,255,255
  56.     Rect n*32,n*32,32,32,1
  57.     Next
  58. Color 0,0,0
  59. For n=0 To 255 Step 32
  60. Line 0,n,255,n
  61. Line n,0,n,255
  62. Next
  63.  
  64. cube_tex=CreateTexture(256,256)
  65. cube=CreateImage(256,256)
  66. GrabImage cube,0,0
  67. CopyRect 0,0,256,256,0,0,ImageBuffer(cube),TextureBuffer(cube_tex)
  68. FreeImage cube
  69.  
  70. ; create cube
  71. cube=CreateCube()
  72. ScaleEntity cube,11,11,11
  73. EntityTexture cube,cube_tex
  74. EntityFX cube,17 ;set fullbright and 2 sided textures
  75. EntityBlend cube,2 ;set multiply blend
  76.  
  77. Repeat
  78.  
  79. ; move the blobs around
  80. For n=0 To max_blobs
  81.     MoveEntity blobs(n),xyblobs(n,0),xyblobs(n,1),xyblobs(n,2)
  82.     ;bounce off sides
  83.     If EntityX(blobs(n))<-10 Or EntityX(blobs(n))>10 Then xyblobs(n,0)=-xyblobs(n,0)
  84.     If EntityY(blobs(n))<-10 Or EntityY(blobs(n))>10 Then xyblobs(n,1)=-xyblobs(n,1)
  85.     If EntityZ(blobs(n))<-10 Or EntityZ(blobs(n))>10 Then xyblobs(n,2)=-xyblobs(n,2)
  86.     Next
  87.  
  88. ; turn camera
  89. TurnEntity middle,.1,.2,.3
  90.  
  91.  
  92. UpdateWorld
  93. RenderWorld
  94. Flip
  95.  
  96.  
  97. Until KeyHit(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement