November 28, 2020, 01:58:52 PM

Author Topic: [bb] Plasma by jfk EO-11110 [ 1+ years ago ]  (Read 375 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Plasma by jfk EO-11110 [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : Plasma
Author : jfk EO-11110
Posted : 1+ years ago

Description : Used for several FX. Seamless Animation

Code :
Code: BlitzBasic
  1. ; This is the Original Source for many of my Plasma-FX.
  2. ; Original QB-Plasma, ported to BB . By CSP 2001.
  3.  
  4. ; Note: Turn Off the Debugger, or it will be way too slow
  5. Graphics 640,480,16,2
  6. SetBuffer BackBuffer()
  7. plasma=CreateImage(320,320)
  8. Dim cosinus(640)
  9. position = 0
  10. For c = 0 To 640
  11.  cosinus(c) = Cos((115*3.14159265358 * c) / 320) * 32 + 32
  12. Next
  13. ;Create some Color Arrays
  14. Dim r(255) : Dim g(255) : Dim b(255) : Dim mrgb(255)
  15. For i=0 To 63 : r(i)=i*4 : g(i)=0 : b(i)=255-(i*4) : Next
  16. For i=0 To 63 : r(i+64)=255-(i*4) : g(i+64)=i*2 : b(i+64)=0 : Next
  17. For i=0 To 63 : r(i+128)=i*2 : g(i+128)=128-(i*2) : b(i+128)=i*4 : Next
  18. For i=0 To 63 : r(i+192)=128+(i*2) : g(i+192)=i : b(i+192)=255-(i*4) : Next
  19. For i=0 To 255 : mrgb(i)=((r(i)*$10000)+(g(i)*$100)+b(i))And $FFFFFF : Next
  20. ; mainloop
  21. While a<>27
  22.  a=GetKey()
  23.  Gosub qbplasma
  24.  Flip
  25. Wend
  26. End
  27. .qbplasma
  28.  wave1 = wave1 + 2
  29.  If wave1 >= 320 Then wave1 = 0
  30.  wave2 = wave2 + 2
  31.  If wave2 >= 320 Then wave2 = 0
  32.  wave3 = wave3 + 3
  33.  If wave3 >= 320 Then wave3 = 0
  34.  SetBuffer ImageBuffer(plasma)
  35.  LockBuffer
  36.    For y = 0 To 319
  37.     d = cosinus(y + wave2) + cosinus(y + wave3)
  38.     For x = 0 To 319
  39.      f = (cosinus(x + wave1) + cosinus(x + y) + d) And $FF
  40.      WritePixelFast x,y,mrgb(f)
  41.    Next
  42.   Next
  43.  UnlockBuffer
  44.  SetBuffer BackBuffer()
  45.  DrawImage plasma,0,0
  46. Return


Comments :


Boiled Sweets(Posted 1+ years ago)

 Awesome.  Can anyone get this to work in 1024 * 768?


xlsior(Posted 1+ years ago)

 1024x768.  A tad slow, though.Note that you can change the 'zoom' factor on this line: cosinus(c) = Cos((115*3.14159265358 * c) / 640) * 32 + 32by changing the '640' to something else.
Code: [Select]
; This is the Original Source for many of my Plasma-FX.
; Original QB-Plasma, ported to BB . By CSP 2001.

; Note: Turn Off the Debugger, or it will be way too slow
Graphics 1024,768,16,2
SetBuffer BackBuffer()
plasma=CreateImage(1024,768)
Dim cosinus(2560)
position = 0
For c = 0 To 2560
 cosinus(c) = Cos((115*3.14159265358 * c) / 640) * 32 + 32
Next
;Create some Color Arrays
Dim r(255) : Dim g(255) : Dim b(255) : Dim mrgb(255)
For i=0 To 63 : r(i)=i*4 : g(i)=0 : b(i)=255-(i*4) : Next
For i=0 To 63 : r(i+64)=255-(i*4) : g(i+64)=i*2 : b(i+64)=0 : Next
For i=0 To 63 : r(i+128)=i*2 : g(i+128)=128-(i*2) : b(i+128)=i*4 : Next
For i=0 To 63 : r(i+192)=128+(i*2) : g(i+192)=i : b(i+192)=255-(i*4) : Next
For i=0 To 255 : mrgb(i)=((r(i)*$10000)+(g(i)*$100)+b(i))And $FFFFFF : Next
; mainloop
While a<>27
 a=GetKey()
 Gosub qbplasma
 Flip
Wend
End
.qbplasma
 wave1 = wave1 + 2
 If wave1 >= 1024 Then wave1 = 0
 wave2 = wave2 + 2
 If wave2 >= 1024 Then wave2 = 0
 wave3 = wave3 + 3
 If wave3 >= 1024 Then wave3 = 0
 SetBuffer ImageBuffer(plasma)
 LockBuffer
   For y = 0 To 1023
    d = cosinus(y + wave2) + cosinus(y + wave3)
    For x = 0 To 1023
     f = (cosinus(x + wave1) + cosinus(x + y) + d) And $FF
     WritePixelFast x,y,mrgb(f)
   Next
  Next
 UnlockBuffer
 SetBuffer BackBuffer()
 DrawImage plasma,0,0
Return



puki(Posted 1+ years ago)

 WHAT!I've never seen this before.I posted a few months ago for plasma routines and nobody had a clue.I love plasma routines.


puki(Posted 1+ years ago)

 That second example is borked - quick edit of original by me ("puki"):
Code: [Select]
; This is the Original Source for many of my Plasma-FX.
; Original QB-Plasma, ported to BB . By CSP 2001.

; Note: Turn Off the Debugger, or it will be way too slow

width=1024
height=768
w2=width/2
Graphics width,height,16,2
SetBuffer BackBuffer()
plasma=CreateImage(width/2,w2)
Dim cosinus(width)
position = 0
For c = 0 To width
 cosinus(c) = Cos((115*3.14159265358 * c) / w2) * 32 + 32
Next
;Create some Color Arrays
Dim r(255) : Dim g(255) : Dim b(255) : Dim mrgb(255)
For i=0 To 63 : r(i)=i*4 : g(i)=0 : b(i)=255-(i*4) : Next
For i=0 To 63 : r(i+64)=255-(i*4) : g(i+64)=i*2 : b(i+64)=0 : Next
For i=0 To 63 : r(i+128)=i*2 : g(i+128)=128-(i*2) : b(i+128)=i*4 : Next
For i=0 To 63 : r(i+192)=128+(i*2) : g(i+192)=i : b(i+192)=255-(i*4) : Next
For i=0 To 255 : mrgb(i)=((r(i)*$10000)+(g(i)*$100)+b(i))And $FFFFFF : Next
; mainloop
While a<>27
 a=GetKey()
 Gosub qbplasma
 Flip
Wend
End
.qbplasma
 wave1 = wave1 + 2
 If wave1 >= w2 Then wave1 = 0
 wave2 = wave2 + 2
 If wave2 >= w2 Then wave2 = 0
 wave3 = wave3 + 3
 If wave3 >= w2 Then wave3 = 0
 SetBuffer ImageBuffer(plasma)
 LockBuffer
   For y = 0 To w2-1
    d = cosinus(y + wave2) + cosinus(y + wave3)
    For x = 0 To w2-1
     f = (cosinus(x + wave1) + cosinus(x + y) + d) And $FF
     WritePixelFast x,y,mrgb(f)
   Next
  Next
 UnlockBuffer
 SetBuffer BackBuffer()
 DrawImage plasma,0,0
Return



xlsior(Posted 1+ years ago)

 what's wrong with the 2nd sample? Seems to work OK without error for me?Your sample doesn't show the plasma effect full screen.


puki(Posted 1+ years ago)

 Well, when I run yours I get a MAV.


puki(Posted 1+ years ago)

 Right, I have re-designed the ultimate version:set width=640 and height=480  for speed.
Code: [Select]
; This is the Original Source for many of my Plasma-FX.
; Original QB-Plasma, ported to BB . By CSP 2001.

; Note: Turn Off the Debugger, or it will be way too slow
width=640
height=480
w2=width/2
Graphics width,height,16,1
SetBuffer BackBuffer()
plasma=CreateImage(width,height)
Dim cosinus(2560)
position = 0
For c = 0 To 2560
 cosinus(c) = Cos((115*3.14159265358 * c) / w2) * 32 + 32
Next
;Create some Color Arrays
Dim r(255) : Dim g(255) : Dim b(255) : Dim mrgb(255)
For i=0 To 63 : r(i)=i*4 : g(i)=0 : b(i)=255-(i*4) : Next
For i=0 To 63 : r(i+64)=255-(i*4) : g(i+64)=i*2 : b(i+64)=0 : Next
For i=0 To 63 : r(i+128)=i*2 : g(i+128)=128-(i*2) : b(i+128)=i*4 : Next
For i=0 To 63 : r(i+192)=128+(i*2) : g(i+192)=i : b(i+192)=255-(i*4) : Next
For i=0 To 255 : mrgb(i)=((r(i)*$10000)+(g(i)*$100)+b(i))And $FFFFFF : Next
; mainloop
While a<>27
 a=GetKey()
 Gosub qbplasma
 Flip
Wend
End
.qbplasma
 wave1 = wave1 + 2
 If wave1 >= width Then wave1 = 0
 wave2 = wave2 + 2
 If wave2 >= width Then wave2 = 0
 wave3 = wave3 + 3
 If wave3 >= width Then wave3 = 0
 SetBuffer ImageBuffer(plasma)
 LockBuffer
   For y = 0 To height-1
    d = cosinus(y + wave2) + cosinus(y + wave3)
    For x = 0 To width-1
     f = (cosinus(x + wave1) + cosinus(x + y) + d) And $FF
     WritePixelFast x,y,mrgb(f)
   Next
  Next
 UnlockBuffer
 SetBuffer BackBuffer()
 DrawImage plasma,0,0
Return


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal