Always in fire KrazyK
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
Congratulation !

Quote from: va!n on April 25, 2019
I continue to fight and wish that someday there will be a few small steps forward in terms of my health.
Then I would like to create more tutorials.
; *************************************************************************************
; * P r o j e c t : T u n n e l - F x
; *************************************************************************************
; *
; * Part7: Moving Tunnel:
; * ---------------------
; * This is the last turorial part, where we will try to get the tunnel fx more
; * interesting while moving the tunnel, by using SIN().
; *
; * Source and Tutorial (c) by Thorsten Will aka va!n
; * All rights reserved.
; *
; *************************************************************************************
DisableDebugger
; -------- Init Code --------
lTextureSize.l = 256
lScreenWidth.l = 640
lScreenHeight.l = 480
Dim aTexture (lTextureSize , lTextureSize )
Dim aDistance (lScreenWidth*2, lScreenHeight*2)
Dim aAngle (lScreenWidth*2, lScreenHeight*2)
Dim aBuffer (lScreenWidth , lScreenHeight )
; -------- Generating Mapping Texture --------
For x.l = 0 To lTextureSize -1
For y.l = 0 To lTextureSize -1
aTexture(x,y) = (x * 256 / lTextureSize) ! (y * 256 / lTextureSize)
Next
Next
; -------- Generating Distance and Angle Table --------
dDistance.d = 32.0
dParts.d = 0.5
For x = 0 To lScreenWidth*2 -1
For y = 0 To lScreenHeight*2 -1
aDistance(x,y) = Int(dDistance * lTextureSize / Sqr( (x-lScreenWidth) * (x-lScreenWidth) + (y-lScreenHeight) * (y-lScreenHeight) )) % lTextureSize
dAngle.d = (dParts * lTextureSize * ATan2(y-lScreenHeight, x-lScreenWidth) / #PI)
aAngle(x,y) = Int (256 - dAngle) & 255
Next
Next
; *************************************************************************************
InitSprite()
OpenWindow(0,0,0,lScreenWidth,lScreenHeight,"",#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,lScreenWidth, lScreenHeight,0,0,0,#PB_Screen_WaitSynchronization )
dSpeedX.d = 1.0
dSpeedY.d = 1.0
Repeat
; ------- Stuff for doing the animation -------
dAnimation.d = dAnimation.d + 0.005
lShiftX.l = Int(lTextureSize * dSpeedX.d * dAnimation.d)
lShiftY.l = Int(lTextureSize * dSpeedY.d * dAnimation.d)
lLookX = lScreenWidth /2 + Int(lScreenWidth /2 * Sin(dAnimation * 4.0 ))
lLookY = lScreenHeight/2 + Int(lScreenHeight/2 * Sin(dAnimation * 6.0 ))
; -------- Calculate Texture coordinates and draw Tunnel -------
StartDrawing(ScreenOutput())
For y = 0 To lScreenHeight-1
For x = 0 To lScreenWidth -1
lCoordinateX.l = (aDistance(x+lLookX, y+lLookY) + lShiftX) % lTextureSize
lCoordinateY.l = (aAngle (x+lLookX, y+lLookY) + lShiftY) % lTextureSize
aBuffer(x,y) = aTexture (lCoordinateX.l , lCoordinateY.l)
Plot(x, y, RGB(0, 0, aBuffer(x,y) ))
Next
Next
StopDrawing()
FlipBuffers()
Until GetAsyncKeyState_(#VK_ESCAPE)
; *************************************************************************************
Page created in 0.108 seconds with 14 queries.