But doing a tunnel in old-school way is still funny:
Code: Select all
screenres 800,600,24
dim shared as unsigned integer LookUpTable (800,600,2)
Dim texture As unsigned integer Ptr = ImageCreate( 247, 247,24 )
BLoad "IvyTexture.bmp", texture
dim as integer x,y
for x=0 to 800
for y=0 to 600
if y=300 then
if x<400 then LookUpTable(x,y,1)=0 else LookUpTable(x,y,1)=1024
else
LookUpTable(x,y,1)=1024*(.5+atn((x-400)/(y-300))/3.1415926)
if y<300 then LookUpTable(x,y,1)+=1024
end if
LookUpTable(x,y,2)= 8388608/((x-400)^2+(y-300)^2)
next
next
dim as unsigned integer t=0
dim as unsigned integer u,v
texture +=8 ' Skip header data
do
dim as unsigned integer ptr target=screenptr
screenlock
for y=1 to 600
for x=1 to 800
u=(LookUpTable(x,y,1) + t) mod 247
v=(LookUpTable(x,y,2) + t) mod 247
*target=*(texture +u*248+v) 'point(u , v , texture)
target+=1
next
next
screenunlock
sleep 1
t+=1
loop until inkey<>""
end
you need this texture:
http://www.math.ucsd.edu/~sbuss/MathCG/OpenGLsoft/FourTextures/IvyTexture.bmp
Note: the above code works in DOS, too (you might have to trim the file name of the texture, if LFN aren't supported)
It's just a port of this tutorial:
http://benryves.com/tutorials/tunnel/1
It's not the first example of that in FreeBasic (relsoft made something similar years ago), but this one is made in pure FB, with no external libraries, and it's about 35 lines of code!