'+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
'+               Mystify by Gareth Bailey                +
'+                    September 2001                     +
'+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +


window origin "lb"
open window 640,512
setup():mystify()

sub setup()
'====setup arrays for polygons====
dim x(24)
dim y(24)
dim dirx(24)
dim diry(24)
'====set initial directions for corners polygons====
for a=1 to 4
read dirx(a)
read diry(a)
next a
for a=5 to 12
if a>4 b=4: if a>8 b=8
dirx(a)=dirx(a-4)
diry(a)=diry(a-4)
next a

for a=13 to 16
read dirx(a)
read diry(a)
next a
for a=17 to 24
dirx(a)=dirx(a-4)
diry(a)=diry(a-4)
next a

'====set initial positions for the corners====
for a=1 to 24
read x(a)
read y(a)
next a
'=====Setup Scroll text=====
txt$=     "Thanks to Adam Lay for provideing the "  
txt$=txt$+"excelent yabasic.co.uk and Nick simpson for "
txt$=txt$+"proviveing the colourful backdrop, Cheers "
txt$=txt$+"guys"
txtend=-30-(len(txt$)*10)
tx=640
ty=25
end sub

sub mystify()
repeat
clear window
draw()

for a=1 to 24
'====move the corners====
x(a)=x(a)+dirx(a)
y(a)=y(a)+diry(a)

'====cheack if the corner has hit the side====
if x(a)<100 dirx(a)=0-(dirx(a))
if x(a)>540 dirx(a)=0-dirx(a)
if y(a)>412 diry(a)=0-diry(a)
if y(a)<100 diry(a)=0-diry(a)
next a
scrolltxt()
db() 
until (peek("port1")=16384)
end sub

sub draw()
cc=cc+0.1
red=50+50*sin(cc/2)
blu=50+50*sin(cc/3)
grn=50+50*sin(cc/4)
setrgb 1,red,30,30
setrgb 2,30,grn,30
setrgb 3,30,30,blu
gtriangle 0,0 to 640,512 to 0,512
gtriangle 0,0 to 640,512 to 640,0

'setrgb 1,0,0,0   :
clear fill rectangle 75,75   to 562,437
setrgb 1,23,23,23: fill rectangle 100,100 to 540,412

c=c+.15
setrgb 1,75+50*sin(c/15),75+50*sin(c/17),75+50*sin(c/20)

for a=0 to 20 step 4
for b=1 to 3
if a>=12 setrgb 1,75+50*sin((c+75)/10),75+50*sin((c+75)/15),75+50*sin((c+75)/20)
line x(b+a),y(b+a) to x((b+1)+a),y((b+1)+a)
next b
line x(a+1),y(a+1) to x(a+4),y(a+4)
next a
end sub

sub scrolltxt()
setrgb 1,75+50*sin((c2)/10),75+50*sin((c2)/10),75+50*sin((c2)/10)
c2=c2+.75
text 100,83,"PRESS 'X' TO QUIT"
setrgb 1,250,250,250 
text tx,ty,txt$ :tx=tx-2
if tx<txtend then: tx=640: ty=25: fi
end sub

sub db()
setdispbuf draw
draw = 1 - draw
setdrawbuf 1 - draw
end sub

'====data for the directions====
data -1,-1,1,1,1,-1,-1,1
data 1,1,-1,-1,-1,1,1,-1

'====data for the positions====
data 200,200,200,300,300,300,300,200
data 205,205,205,305,305,305,305,205
data 210,210,210,310,310,310,310,210
data 150,150,250,150,150,250,250,250
data 155,155,255,155,155,255,255,255
data 160,160,260,160,160,260,260,260








