TGC Codebase Backup



Doctor Who 2DTimetunnel by MonoCoder

28th Jan 2006 7:26
Summary

Doctor Who Timetunnel made in 2D.



Description

Uses 2D drawing commands to create a simple timetunnel effect that controls it's movement with cosine/sine. Use the left/right/both mouse buttons to change the tunnel's shape. The tunnel also changes color automatically. Have fun.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Sync on
Sync Rate 0

remstart
tunnel#()
1  x pos
2  y pos
3  size
4  color
5  active
remend

max=500
Dim tunnel#(max,5)

mx=mousex()
my=mousey()
nextcircle=1
newcircledelay=0
red=200
green=20
blue=80
redcos#=0
greencos#=0
bluecos#=0
t=0
thickrad=1
tunnelmovement#=0

Do

x=screen width()/2+(cos(redcos#)*120)+(cos(tunnelmovement#)*40)
y=screen height()/2+(sin(greencos#)*60)+(sin(tunnelmovement#)*40)

tunnelmovement#=wrapvalue(tunnelmovement#+1)

newcircledelay=newcircledelay+1
If newcircledelay=8
newcircledelay=0
tunnel#(nextcircle,1)=x
tunnel#(nextcircle,2)=y
tunnel#(nextcircle,3)=1
tunnel#(nextcircle,4)=rgb(red,green,blue)
tunnel#(nextcircle,5)=1
nextcircle=nextcircle+1
If nextcircle>max then nextcircle=1
Endif

redcos#=wrapvalue(redcos#+0.4)
greencos#=wrapvalue(greencos#+0.8)
bluecos#=wrapvalue(bluecos#+0.13)
red=128+(cos(redcos#)*100)
green=128+(cos(greencos#)*100)
blue=128+(cos(bluecos#)*100)
If red<0 then red=0 : If red>255 then red=255
If green<0 then green=0 : If green>255 then green=255
If blue<0 then blue=0 : If blue>255 then blue=255

For n=1 to max
If tunnel#(n,5)=1
tunnel#(n,3)=tunnel#(n,3)+(tunnel#(n,3)/50)
If tunnel#(n,3)>1000 then tunnel#(n,5)=0
Endif
Next n

Lock pixels

For n=max to 1 step -1
If tunnel#(n,5)=1
Ink tunnel#(n,4),0
If mouseclick()=0 then circle tunnel#(n,1),tunnel#(n,2),tunnel#(n,3)
If mouseclick()=1
Line tunnel#(n,1)-tunnel#(n,3),tunnel#(n,2)-tunnel#(n,3),tunnel#(n,1)+tunnel#(n,3),tunnel#(n,2)-tunnel#(n,3)
Line tunnel#(n,1)-tunnel#(n,3),tunnel#(n,2)-tunnel#(n,3),tunnel#(n,1)-tunnel#(n,3),tunnel#(n,2)+tunnel#(n,3)
Line tunnel#(n,1)+tunnel#(n,3),tunnel#(n,2)-tunnel#(n,3),tunnel#(n,1)+tunnel#(n,3),tunnel#(n,2)+tunnel#(n,3)
Line tunnel#(n,1)-tunnel#(n,3),tunnel#(n,2)+tunnel#(n,3),tunnel#(n,1)+tunnel#(n,3),tunnel#(n,2)+tunnel#(n,3)
Endif
If mouseclick()=2
Line tunnel#(n,1)-tunnel#(n,3),tunnel#(n,2)+tunnel#(n,3),tunnel#(n,1),tunnel#(n,2)-tunnel#(n,3)
Line tunnel#(n,1)+tunnel#(n,3),tunnel#(n,2)+tunnel#(n,3),tunnel#(n,1),tunnel#(n,2)-tunnel#(n,3)
Line tunnel#(n,1)-tunnel#(n,3),tunnel#(n,2)+tunnel#(n,3),tunnel#(n,1)+tunnel#(n,3),tunnel#(n,2)+tunnel#(n,3)
Endif
If mouseclick()=3
Line tunnel#(n,1)-tunnel#(n,3),tunnel#(n,2)-tunnel#(n,3),tunnel#(n,1),tunnel#(n,2)+tunnel#(n,3)
Line tunnel#(n,1)+tunnel#(n,3),tunnel#(n,2)-tunnel#(n,3),tunnel#(n,1),tunnel#(n,2)+tunnel#(n,3)
Line tunnel#(n,1)-tunnel#(n,3),tunnel#(n,2)-tunnel#(n,3),tunnel#(n,1)+tunnel#(n,3),tunnel#(n,2)-tunnel#(n,3)
Endif
Endif
Next n

Unlock pixels

Sync
Cls rgb(red/10,green/10,blue/10)
Loop