DemoCoding - OldSkool Twister Effect
Posted: Sun Jan 20, 2008 12:16 am
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