November 24, 2020, 07:08:58 AM

Author Topic: [bb] Rubber by Equinox [ 1+ years ago ]  (Read 724 times)

Offline BlitzBot

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

Description : Here is a rubber effect I did way back in the amiga days.

Code :
Code: BlitzBasic
  1. Frames=48 ;should divide exactly into screen height
  2. ScreenWidth=640
  3. ScreenHeight=480
  4.  
  5. Graphics3D ScreenWidth,ScreenHeight,16,1
  6.  
  7. tex=CreateTexture( 64,64 )
  8. SetBuffer TextureBuffer( tex )
  9. Color 255,0,0:Rect 0,0,32,32:Rect 32,32,32,32
  10. Color 255,128,0:Rect 32,0,32,32:Rect 0,32,32,32
  11. SetBuffer BackBuffer()
  12. Color 255,255,255
  13.  
  14. cone=CreateCone(20)
  15. PositionEntity cone,0,0,0
  16. EntityTexture cone,tex
  17.  
  18. light=CreateLight()
  19. TurnEntity light,45,45,0
  20.  
  21. pivot=CreatePivot()
  22. camMain=CreateCamera(pivot)
  23. PositionEntity camMain,0,0,-3
  24.  
  25.  
  26. ;Initialse Frame Buffers
  27. Dim imgImages(Frames-1)
  28.  
  29. For Loop1=0 To Frames-1
  30.         imgImages(Loop1)=CreateImage(ScreenWidth,ScreenHeight)
  31. Next
  32. ImgCount=0
  33.  
  34. While Not KeyHit(1)
  35.  
  36.         ;Rotate Our Object
  37.         X=X+1.0
  38.         Y=Y+0.5
  39.         z=z+0.8
  40.         If x>=360 Then x=x-360
  41.         If y>=360 Then y=y-360
  42.         If z>=360 Then z=z-360
  43.         RotateEntity cone,x,y,z
  44.  
  45.         ;Update & Render The World
  46.         UpdateWorld
  47.         RenderWorld
  48.        
  49.         ;Generate Next Frame Buffer Pos
  50.         ImgCount=ImgCount+1    
  51.         If ImgCount>Frames-1 Then ImgCount=0
  52.        
  53.         ;Store Frame To Buffer
  54.         SetBuffer ImageBuffer(imgImages(ImgCount))
  55.         CopyRect 0,0,ScreenWidth,ScreenHeight,0,0,BackBuffer(),ImageBuffer(imgImages(ImgCount))
  56.         SetBuffer BackBuffer()
  57.        
  58.         ;Render Each Section Of Screen Downwards As Previous Image Than One Above
  59.         ImgPos=ImgCount
  60.         For Loop1=0 To Frames-1
  61.                 CopyRect 0,(ScreenHeight/Frames)*Loop1,ScreenWidth,(ScreenHeight/Frames),0,(ScreenHeight/Frames)*Loop1,ImageBuffer(imgImages(ImgPos)),BackBuffer()
  62.                 ImgPos=ImgPos-1
  63.                 If ImgPos<0 Then ImgPos=Frames-1
  64.         Next
  65.  
  66.         Flip
  67.  
  68. Wend
  69.  
  70. End


Comments :


Clyde(Posted 1+ years ago)

 Very neat looking routine Equinox!Cheers :)


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal