sync on
hide mouse
 
Hiscores=10
dim Hiname$(Hiscores)
dim HiValue(Hiscores)
 
dim Hinmpxl(Hiscores,100,20)
dim Hivlpxl(Hiscores,50,20)
 
dim Hinmbld(Hiscores,100,20)
dim Hivlbld(Hiscores,50,20)
 
set text font "courier new"
set text size 16
sync
for i=1 to Hiscores
 
   read name$
   read value
   Hiname$(i)=name$
   Hivalue(i)=value
 
   ink rgb(255,255,255),0
 
   tilex1=text width(Hiname$(i))
   tiley1=12
   tilex2=text width(str$(Hivalue(i)))
   tiley2=12
 
   cls
   text 0,0,Hiname$(i)
   filen$=Hiname$(i)+" name.bmp"
   get image i*2-1,0,0,tilex1,tiley1
   if file exist(filen$)=1 then delete file filen$
   save image filen$,i*2-1
 
   cls
   text 0,0,str$(Hivalue(i))
   get image i*2,0,0,tilex2,tiley2
   filev$=Hiname$(i)+" value.bmp"
   if file exist(filev$)=1 then delete file filev$
   save image filev$,i*2
 
   sync
   ConvertTextToPixels(i,tilex1,tiley1,tilex2,tiley2)
 
   ConvertTextToBuilding(i,tilex1,tiley1,tilex2,tiley2)
 
next i
 
gosub gettextures
 
cls
backdrop on
color backdrop 0
fog on
fog color 0
fog distance 2000
make object plain 1,3000,10000
xrotate object 1,90
position object 1,300,-5,1200
color object 1,rgb(100,100,100)
sync
 
object=1
for i=1 to Hiscores
   tilex1=text width(Hiname$(i))
   tiley1=12
   tilex2=text width(str$(Hivalue(i)))
   tiley2=12
   for x=1 to tilex1
      for y=1 to tiley1
         if Hinmbld(i,x,y)=1
            object=object+1
            make object cube object,10
            color object object,rgb(0,0,155)
            make mesh from object 1,object
            add limb object,1,1
            scale limb object,1,40,40,1
            color limb object,1,rgb(255,255,0)
            offset limb object,1,0,0,-5.0
            position object object,x*10,(tiley1-y)*10,i*350-350
         endif
         if Hinmbld(i,x,y)=2
            object=object+1
            make object cube object,10
            texture object object,1001
            set object object,1,0,1
            position object object,x*10,(tiley1-y)*10,i*350-350
         endif
      next y
   next x
   extrax=tilex1*10+50
   for x=1 to tilex2
      for y=1 to tiley2
         if Hivlbld(i,x,y)=1
            object=object+1
            make object cube object,10
            color object object,rgb(0,0,155)
            make mesh from object 1,object
            add limb object,1,1
            scale limb object,1,40,40,1
            color limb object,1,rgb(255,255,0)
            offset limb object,1,0,0,-5.0
            position object object,x*10+extrax,(tiley1-y)*10,i*350-350
         endif
         if Hivlbld(i,x,y)=2
            object=object+1
            make object cube object,10
            texture object object,1001
            set object object,1,0,1
            position object object,x*10+extrax,(tiley1-y)*10,i*350-350
         endif
      next y
   next x
next i
 
sync rate 40
 
hiscoreon=1
targetx#=(text width(Hiname$(hiscoreon))+text width(str$(Hivalue(hiscoreon))))/2*10+30
targety#=220
targetz#=((hiscoreon*300)-300)-500
 
position camera targetx#,targety#,targetz#
 
do
 
   set cursor 0,0
 
   upcount=upcount-1
   dncount=dncount-1
   if upkey()=1 and upcount<0 and hiscoreon<Hiscores
      hiscoreon=hiscoreon+1
      targetx#=(text width(Hiname$(hiscoreon))+text width(str$(Hivalue(hiscoreon))))/2*10
      targety#=220
      targetz#=((hiscoreon*350)-350)-(text width(Hiname$(hiscoreon))+text width(str$(Hivalue(hiscoreon))))/2*14
      upcount=10
   endif
   if downkey()=1 and dncount<0 and hiscoreon>1
      hiscoreon=hiscoreon-1
      targetx#=(text width(Hiname$(hiscoreon))+text width(str$(Hivalue(hiscoreon))))/2*10
      targety#=220
      targetz#=((hiscoreon*350)-350)-(text width(Hiname$(hiscoreon))+text width(str$(Hivalue(hiscoreon))))/2*14
      dncount=10
   endif
 
   currentx#=camera position x()
   currenty#=camera position y()
   currentz#=camera position z()
 
   if currentx#<>targetx#
      currentx#=currentx#+((targetx#-currentx#)/10)
   endif
   if currentz#<>targetz#
      currentz#=currentz#+((targetz#-currentz#)/10)
   endif
 
   position camera currentx#,currenty#,currentz#
 
   print hiscoreon
 
   sync
 
loop
 
end
 
gettextures:
 
   x1=1
   y1=1
   x2=64
   y2=64
 
   ink rgb(150,80,0),0
 
   drawaline(x1+3-2,y1+3-2,x1+3-2,y2-2,4)
   drawaline(x1+3-2,y2-2,x2-2,y2-2,4)
   drawaline(x2-2,y2-2,x2-2,y1+3-2,4)
   drawaline(x2-2,y1+3-2,x1+3-2,y1+3-2,4)
 
   drawaline(x1+3-2,y1+3-2,x2-2,y2-2,4)
   drawaline(x1+3-2,y2-2,x2-2,y1+3-2,4)
 
   get image 1001,x1,y1,x2,y2
 
return
 
function drawaline(x1,y1,x2,y2,thickness)
 
   unit$=right$(str$(thickness),1)
   if unit$="1" or unit$="3" or unit$="5" or unit$="7" or unit$="9"
      print 1
      odd=1
      hth#=(thickness+1)/2
   else
      odd=0
      hth#=thickness/2
   endif
   angle#=atanfull((x2-x1),(y2-y1))
   angle#=wrapvalue((360-angle#)-270)
   d#=0
   x=x1
   y=y1
   distance#=sqrt((x1-x2)^2+(y1-y2)^2)
 
   for d=0 to distance#*2
      d#=d#+0.5
      tx=cos(angle#)*d#
      ty=sin(angle#)*d#
      x=x1+tx
      y=y1+ty
      if odd=1 then box x-hth#,y-hth#,(x-hth#)+thickness-1,(y-hth#)+thickness-1 else box x-hth#,y-hth#,x+hth#-1,y+hth#-1
   next d
 
endfunction
 
function ConvertTextToPixels(number,tilex1,tiley1,tilex2,tiley2)
 
   for i=1 to 2
      extra=0
      if i=1
         file$=Hiname$(number)+" name.bmp"
         imgwidth=tilex1
         imgheight=tiley1
      else
         file$=Hiname$(number)+" value.bmp"
         imgwidth=tilex2
         imgheight=tiley2
      endif
      fsize=file size(file$)
      bmapsize=fsize-53-1
      pad1=3*(imgwidth+1)*(imgheight+1)
      pad2=bmapsize-pad1
      padding=pad2/(imgheight+1)
      open to read 1,file$
      for skip = 1 to 53
         read byte 1,a
      next skip
      for y=imgheight to 1 step -1
         for x=1 to imgwidth
            read byte 1,b
            read byte 1,g
            read byte 1,r
            a=rgb(r,g,b)
            ink a,0
            dot x,y
            if a=16578808 or a=16578560
               if i=1 then Hinmpxl(number,x,y)=1 else Hivlpxl(number,x,y)=1
            endif
         next x
         for pad=1 to padding
            read byte 1,skip
         next pad
      next y
      close file 1
   next i
 
endfunction
 
 
function ConvertTextToBuilding(number,tilex1,tiley1,tilex2,tiley2)
 
   for x=1 to tilex1
      for y=1 to tiley1
         Hinmbld(number,x,y)=Hinmpxl(number,x,y)
      next y
   next x
   for x=1 to tilex2
      for y=1 to tiley2
         Hivlbld(number,x,y)=Hivlpxl(number,x,y)
      next y
   next x
 
   for x=1 to tilex1
      for y=1 to tiley1
         if Hinmbld(number,x,y)=1
            for i=y to tiley1
               if Hinmbld(number,x,i)=0 then Hinmbld(number,x,i)=2
            next i
            exit
         endif
      next y
   next x
   for x=1 to tilex2
      for y=1 to tiley2
         if Hivlbld(number,x,y)=1
            for i=y to tiley2
               if Hivlbld(number,x,i)=0 then Hivlbld(number,x,i)=2
            next i
            exit
         endif
      next y
   next x
 
endfunction
 
data "TDK",4650
data "Sinani",4570
data "Latch",4390
data "LBFN",4120
data "INH",4090
data "Obese",3820
data "Phaelax",3720
data "CRobski",3560
data "Lukas W",3330
data "Nano",3040