REM 3D stretchy vector tunnel v.1
REM I optimized my tunnel. Enjoy
REM v.1
REM updated brightness fade in and out
REM
DIM x(81)
DIM y(81)
DIM z(81)
DIM tx(81)
DIM ty(81)
DIM orz(81)
graphics
ox=Screen_Width()/2  'offset x
oy=Screen_Height()/2  'offset y
oz=0
dzb=.1
zbrightness=.1 '.1 - 60 - larger brighter
'top/bottom color large number is domonent 
r1=.4
g1=.4
b1=.10
'walls color large number is domonent 
r2=.4
g2=.4
b2=.30
'read tunnel data
FOR a=1 TO 80
    READ x(a), y(a), z(a)
    orz(a)=z(a)
NEXT a 
loop:
zbrightness=zbrightness+dzb
IF zbrightness > 20 OR zbrightness < .1 THEN
    dzb=-dzb
END IF 
refresh off
graphics clear
GOSUB draw
refresh on 
GOTO loop
draw:
mc=mc+1
mc2=mc2+1
mmm=80+80*SIN(mc2/15)
'Sine table for faster lookup
FOR a=1 TO 60
    sofx=(80*SIN((a+mc)/15))+ox
    sofy=(mmm*COS((a+mc)/15))+oy
    tx(a)=(x(a)*(z(a)*z(a)/2))+sofx
    ty(a)=(y(a)*(z(a)*z(a)/2))+sofy
    z(a)=z(a)+zbrightness 
NEXT a
'Four triangles for the left and right walls.
'Four triangles for the top and bottom.
'A flex box on top, bottom, left, right.
FOR a=1 TO 50 STEP 4
    fill COLOR r1*z(a)/25, g1*z(a)/25, b1*z(a)/25
    'fill triangle tx(a),ty(a) to tx(a+1),ty(a+1) to tx(a+5),ty(a+5)
    x1=tx(a)
    y1=ty(a)
    x2=tx(a+1)
    y2=ty(a+1) 
    x3=tx(a+5)
    y3=ty(a+5)
    GOSUB ftriangle
    'fill triangle tx(a),ty(a) to tx(a+4),ty(a+4) to tx(a+5),ty(a+5)
    x1=tx(a)
    y1=ty(a)
    x2=tx(a+4)
    y2=ty(a+4) 
    x3=tx(a+5)
    y3=ty(a+5)
    GOSUB ftriangle
    'fill triangle tx(a+2),ty(a+2) to tx(a+3),ty(a+3) to tx(a+7),ty(a+7)
    x1=tx(a+2)
    y1=ty(a+2)
    x2=tx(a+3)
    y2=ty(a+3) 
    x3=tx(a+7)
    y3=ty(a+7)
    GOSUB ftriangle
    'fill triangle tx(a+2),ty(a+2) to tx(a+6),ty(a+6) to tx(a+7),ty(a+7)
    x1=tx(a+2)
    y1=ty(a+2)
    x2=tx(a+6)
    y2=ty(a+6) 
    x3=tx(a+7)
    y3=ty(a+7)
    GOSUB ftriangle
    
    fill COLOR r2*z(a)/25, g2*z(a)/25,b2*z(a)/25
    'fill triangle tx(a+1),ty(a+1) to tx(a+6),ty(a+6) to tx(a+5),ty(a+5)
    x1=tx(a+1)
    y1=ty(a+1)
    x2=tx(a+6)
    y2=ty(a+6) 
    x3=tx(a+5)
    y3=ty(a+5)
    GOSUB ftriangle
    'fill triangle tx(a+1),ty(a+1) to tx(a+2),ty(a+2) to tx(a+6),ty(a+6)
    x1=tx(a+1)
    y1=ty(a+1)
    x2=tx(a+2)
    y2=ty(a+2) 
    x3=tx(a+6)
    y3=ty(a+6)
    GOSUB ftriangle
    'fill triangle tx(a),ty(a) to tx(a+7),ty(a+7) to tx(a+4),ty(a+4)
    x1=tx(a)
    y1=ty(a)
    x2=tx(a+7)
    y2=ty(a+7) 
    x3=tx(a+4)
    y3=ty(a+4)
    GOSUB ftriangle
    'fill triangle tx(a),ty(a) to tx(a+7),ty(a+7) to tx(a+3),ty(a+3) 
    x1=tx(a)
    y1=ty(a)
    x2=tx(a+7)
    y2=ty(a+7) 
    x3=tx(a+3)
    y3=ty(a+3)
    GOSUB ftriangle
NEXT a
IF z(1)>=orz(1)+1 THEN
    mc=mc-4
    FOR a=1 TO 80
        z(a)=orz(a)+.1
    NEXT a
END IF
RETURN
DATA -5,-5,0 ,5,-5,0 ,5,5,0 ,-5,5,0 
DATA -5,-5,1 ,5,-5,1 ,5,5,1 ,-5,5,1
DATA -5,-5,2 ,5,-5,2 ,5,5,2 ,-5,5,2
DATA -5,-5,3 ,5,-5,3 ,5,5,3 ,-5,5,3
DATA -5,-5,4 ,5,-5,4 ,5,5,4 ,-5,5,4
DATA -5,-5,5 ,5,-5,5 ,5,5,5 ,-5,5,5
DATA -5,-5,6 ,5,-5,6 ,5,5,6 ,-5,5,6
DATA -5,-5,7 ,5,-5,7 ,5,5,7 ,-5,5,7
DATA -5,-5,8 ,5,-5,8 ,5,5,8 ,-5,5,8
DATA -5,-5,9 ,5,-5,9 ,5,5,9 ,-5,5,9
DATA -5,-5,10 ,5,-5,10 ,5,5,10 ,-5,5,10
DATA -5,-5,11 ,5,-5,11 ,5,5,11 ,-5,5,11
DATA -5,-5,12 ,5,-5,12 ,5,5,12 ,-5,5,12
DATA -5,-5,13 ,5,-5,13 ,5,5,13 ,-5,5,13
DATA -5,-5,14 ,5,-5,14 ,5,5,14 ,-5,5,14
DATA -5,-5,15 ,5,-5,15 ,5,5,15 ,-5,5,15
DATA -5,-5,16 ,5,-5,16 ,5,5,16 ,-5,5,16
DATA -5,-5,17 ,5,-5,17 ,5,5,17 ,-5,5,17
DATA -5,-5,18 ,5,-5,18 ,5,5,18 ,-5,5,18
DATA -5,-5,19 ,5,-5,19 ,5,5,19 ,-5,5,19
'Fill Triangle
ftriangle:
DIM xs(3),ys(3)
xs(0)=x1
ys(0)=y1
xs(1)=x2
ys(1)=y2
xs(2)=x3
ys(2)=y3
fill poly xs,ys count 3
RETURN
			
							3D stretchy vector tunnel v.1
- 
				DrChip
 - Posts: 167
 - Joined: Wed Oct 22, 2014 3:26 pm
 - My devices: iPhone 4 to 6+,iPad mini to iPad air 2
 
3D stretchy vector tunnel v.1
- Attachments
 - 
			
		
				
- image.jpg (152.13 KiB) Viewed 2625 times
 
 - 
			
		
				
- image.jpg (130.83 KiB) Viewed 2625 times
 
 - 
			
		
				
- image.jpg (117.2 KiB) Viewed 2625 times