Ooops
November 28, 2020, 01:04:31 PM

Author Topic: [bb] BBThugha by johnpeat [ 1+ years ago ]  (Read 1143 times)

Offline BlitzBot

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

Description : Converted from JCthugha just to 'test out' BB's raw processing speed - which is about on a par with MSIE-based Java...

Code :
Code: BlitzBasic
  1. ; Converted from JCthugha
  2. ; http://www.afn.org/~cthugha/ for much much more...
  3. ;
  4. ; Blitz Note: Disable Debug or this runs WAY too slow...
  5.  
  6. ;Set screen size
  7. Const gwidth=400,gheight=200
  8. Graphics gwidth,gheight,16,2
  9.  
  10. Dim snd(gwidth)
  11.  
  12. Dim col(256)
  13. Dim colmap(gwidth,gheight)
  14.  
  15. ; Make a "palette"
  16. For i = 0 To 63
  17.         col(i)=i*4*256*256 ; Reds
  18.         col(i+64)=i*4*256 ; Greens
  19.         col(i+128)=i*4 ; Blues
  20.         col(i+192)=i*4*256*256+i*4*256+i*4 ; Greys
  21. Next
  22.  
  23.  
  24. Repeat
  25.        
  26.         ; Fake a 'sound wave'
  27.         snd(0) = Rand(-gheight/3,gheight/3)
  28.         For i = 1 To gwidth-1
  29.                 snd(i) = snd(i-1) + Rand(-10,10)
  30.                 If snd(i) < -gheight Then snd(i) = snd(i) = 2*gheight
  31.                 If snd(i) > gheight  Then snd(i) = snd(i) - 2*gheight
  32.         Next
  33.  
  34.         ;Draw black outline to ensure 'flameout'
  35.         Color 0,0,0
  36.         Line 0,0,gwidth-1,0
  37.         Line 0,gheight-1,gwidth-1,gheight-1
  38.         Line 0,0,0,gheight
  39.         Line gwidth-1,0,gwidth-1,gheight-1
  40.  
  41.         LockBuffer FrontBuffer()
  42.  
  43.         ; 'Flame' effect
  44.         For x = 0 To gwidth-1
  45.                 For y = 0 To gheight-2
  46.                         p1 = colmap(x+1,y)
  47.                         p2 = colmap(x,y+1)
  48.                 p3 = colmap(x+1,y+1)
  49.                         p4 = colmap(x,y)
  50.                         If  p1 < 0 Then p1 = p1 + 256
  51.                         If  p2 < 0 Then p2 = p2 + 256
  52.                         If  p3 < 0 Then p3 = p3 + 256
  53.                         If  p4 < 0 Then p4 = p4 + 256
  54.                         s = p1 + p2 + p3 + p4;
  55.                         s = s / 4;
  56.                         If s > 0 Then s = s - 1
  57.                         colmap(x,y)=s
  58.                 WritePixelFast x,y,col(s)
  59.                 Next
  60.                 colmap(x,gheight/2+snd(x)/3)=255
  61.                 WritePixelFast x,gheight/2+snd(x)/3,$ffffff ; White
  62.         Next
  63.  
  64.         UnlockBuffer FrontBuffer()
  65.  
  66. Until KeyHit(1)
  67.  
  68. End


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal