Ooops
November 30, 2020, 02:00:28 AM

Author Topic: [bb] chaos cube by Vignoli [ 1+ years ago ]  (Read 582 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] chaos cube by Vignoli [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : chaos cube
Author : Vignoli
Posted : 1+ years ago

Description : This program makes an entity rotate around coordinates 0,0,0 but using the theory of chaos.
Usefull for 3d games in space.


Code :
Code: BlitzBasic
  1. ; chaos cube
  2.  
  3. chn=30 ; change this for more or less chaos
  4.  
  5. Graphics3D 800,600,32,2
  6. SetBuffer BackBuffer()
  7. SeedRnd MilliSecs()
  8.  
  9. camera=CreateCamera()
  10. AmbientLight 200,200,200
  11. PositionEntity camera,0,0,-300
  12.  
  13. Dim ang(chn,3)
  14. Dim sens(chn,3)
  15. Dim speed#(chn,3)
  16.  
  17. For i=1 To chn
  18.         For j=1 To 3
  19.                 ang(i,j)=Rand(0,359)
  20.                 sens(i,j)=Rand(0,1)
  21.                 If sens(i,j)=0 Then sens(i,j)=-1
  22.                 speed#(i,j)=Rand(5,200)
  23.                 speed#(i,j)=speed#(i,j)/10.0
  24.         Next
  25. Next
  26.  
  27. cube=CreateCube()
  28. ScaleEntity cube,10,5,20
  29.  
  30. Repeat
  31.  
  32. If KeyDown(1) Then End
  33.  
  34. PositionEntity cube,0,0,0
  35. For i=1 To chn
  36.         RotateEntity cube,ang(i,1),ang(i,2),ang(i,3)
  37.         MoveEntity cube,speed#(i,1),speed#(i,2),speed#(i,3)
  38.         For j=1 To 3
  39.                 ang(i,j)=ang(i,j)+Int(sens(i,j)*speed#(i,j))
  40.                 While ang(i,j)<0
  41.                         ang(i,j)=ang(i,j)+360
  42.                 Wend
  43.                 While ang(i,j)>359
  44.                         ang(i,j)=ang(i,j)-360
  45.                 Wend
  46.                 If KeyDown(1) Then End
  47.         Next
  48. Next
  49.  
  50. UpdateWorld
  51. RenderWorld
  52. Color 255,255,255
  53. Text 0,0,"Push [Return] to randomize the chaos"
  54. Flip
  55.  
  56. If KeyDown(28)
  57. SeedRnd MilliSecs()
  58. For i=1 To chn
  59.         For j=1 To 3
  60.                 ang(i,j)=Rand(0,359)
  61.                 sens(i,j)=Rand(0,1)
  62.                 If sens(i,j)=0 Then sens(i,j)=-1
  63.                 speed#(i,j)=Rand(5,200)
  64.                 speed#(i,j)=speed#(i,j)/10.0
  65.         Next
  66. Next
  67. While KeyDown(28) : Wend
  68. EndIf
  69.  
  70. tt1=MilliSecs()
  71. While MilliSecs()-tt1<50
  72.         If KeyDown(1) Then End
  73. Wend
  74.  
  75.  
  76. Forever
  77.  
  78. End


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal