DemoCoding - OldSkool Twister Effect

Share your advanced PureBasic knowledge/code with the community.
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

DemoCoding - OldSkool Twister Effect

Post by va!n »

just another oldskool demo effect i want to share here... have fun...

Code: Select all

; --------------------------------------------------------------
;
; OldSkool DemoEffect:  Twister
;
; Code by: Thorsten Will aka Mr.Vain/Secretly! in 2007
;
; --------------------------------------------------------------

lScreenW = 640            ; Width
lScreenH = 480            ; Height
lScreenD = 32             ; Depth
lCenterX = lScreenW / 2

InitSprite()
OpenScreen( lScreenW, lScreenH, lScreenD, "Twist Experience by va!n")
 
; -------- Define Colors in an array --------
 
    Dim aColor (4,3)
    
    aColor(0,0) =         255 : aColor(0,1) =           0 : aColor(0,2) =           0
    aColor(1,0) =           0 : aColor(1,1) =           0 : aColor(1,2) =         255
    aColor(2,0) =           0 : aColor(2,1) =         255 : aColor(2,2) =           0
    aColor(3,0) =         255 : aColor(3,1) =         255 : aColor(3,2) =           0
    aColor(4,0) = aColor(0,0) : aColor(4,1) = aColor(0,1) : aColor(4,2) = aColor(0,2)
    
; -------- Define some Twist settings --------

     ascale.f = 3.14/180 
     lTwistWidth = 100
     inc.f       =   1.0            ; drehungs start pos
     iinc.f      =   0.01           ; drehungs speed
     a.f         =   0.25

; -------- Mainloop --------

Repeat
  ClearScreen($0)
  StartDrawing(ScreenOutput())

      ; -------- Reset Values --------
       
    	a   = 0
    	inc = inc + iinc
    
    	For y = 0 To lScreenH+Abs(inc)
      		x1 = lTwistWidth * (4+Abs(inc))/4 * Sin(a*ascale)
      		x2 = lTwistWidth * (4+Abs(inc))/4 * Cos(a*ascale)
      		
      		x1 = Abs(x1)
      		x2 = Abs(x2)
      		
      		q = Int(a/90)
      
       		If q & 1 <> 0 
             Swap x1,x2        ;		t = x1 : x1 = x2 : x2 = t   
       	  EndIf
      
        	ow = lCenterX-((x1+x2)/2)
       		LineXY (   ow, y,    ow+x1, y, RGB( aColor(q+1,0), aColor(q+1,1), aColor(q+1,2) ))
      	  LineXY (ow+x1, y, ow+x1+x2, y, RGB( aColor(q  ,0), aColor(q  ,1), aColor(q  ,2) ))
      		
      		a = a + inc /2
      		
      		If Int(a) <=   0 : a = a + 360 : EndIf
      		If Int(a) >= 360 : a = a - 360 : EndIf
    	Next
    
    	If inc > 2 Or inc < -2 : iinc = -iinc : EndIf 
  StopDrawing()
  
  ; -------- Lets the show start --------
  
  FlipBuffers(1)
  Delay(1)

Until GetAsyncKeyState_(#VK_ESCAPE)
End
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

Good job.
Are there more fx where this fx is coming from? ^^
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post by va!n »

yes, i have fnished some other fx in the past too... some stuff can be found here when searching for the keyword "DemoCoding". have a nice day :)
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Very nice.

Thanks.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Very good!
Never seen that effect in my older times :D
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Blue
Addict
Addict
Posts: 967
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Post by Blue »

Very well done.

Love it.

Thanks.
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post by djes »

I did something similar an Amiga, but it was a vertical scrolltext, with the copper. I don't remember the Anarchy's demo where there was one too (but I was the first :P)
Post Reply