` One Hole of Golf 6/8/07 LBFN randomize 128649 sync on : sync rate 42 autocam off draw to front TilesX=60 TilesZ=20 Dim MatX#(TilesX) Dim MatZ#(TilesZ) Dim MHeight#(60,20) make matrix 2,750,250,60,20 SET MATRIX 2, 1, 0, 1, 1, 0, 0, 0 `SET MATRIX Matrix Number, Wireframe, Transparency, Cull, Filter, Light, Fog, Ambient set ambient light 60 set directional light 0,-1.0,0.0,0.0 gosub MAKE_TEXTURES gosub normalise gosub SET_TILES_MTX2 POSITION CAMERA -5.3,10.0,96.7 point camera 483.2,10.0,146.6 ` make cup, flagstick and flag make object cylinder 22,1 make object cylinder 23,10 texture object 23,101 make object plain 24,2,2 texture object 24,100 scale object 23,2,100,2 opy = GET GROUND HEIGHT(2, 531.6, 80.4) position object 22,531.6,2.98,80.4 position object 23,531.6,(opy+5.0),80.4 position object 24,531.6,(opy+9.0),79.4 yrotate object 24,90 ` make tee markers ` men's make object sphere 25,1.5 th#=get ground height(2,25,111)+.15 position object 25,25,th#,111 color object 25,rgb(0,64,128) make object sphere 26,1.5 th#=get ground height(2,25,89)+.15 position object 26,25,th#,89 color object 26,rgb(0,64,128) ` womens make object sphere 27,1.5 th#=get ground height(2,150,161)+.15 position object 27,150,th#,161 color object 27,rgb(192,34,0) make object sphere 28,1.5 th#=get ground height(2,150,139)+.15 position object 28,150,th#,139 color object 28,rgb(192,34,0) ` sign, sign everywhere's a sign make object plain 29,10.0,7.0 position object 29,23,10,120 yrotate object 29,75 SET OBJECT TEXTURE 29, 2, 0 texture object 29,102 make object cylinder 30,7 scale object 30,7,100,7 position object 30,22.71,3.2,122 color object 30,rgb(128,64,0) make object cylinder 31,7 scale object 31,7,100,7 position object 31,23.75,3.2,118 color object 31,rgb(128,64,0) gosub MAKE_UNDULATIONS gosub smooth ` MAIN LOOP &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& do if upkey()=1 then move camera 5 if downkey()=1 then move camera -5 if leftkey()=1 then y#=wrapvalue(camera angle y()-2.5) : yrotate camera y# if rightkey()=1 then y#=wrapvalue(camera angle y()+2.5) : yrotate camera y# if mouseclick()=2 then exit remstart ` debug set cursor 0,0 print "pos x=";camera position x() print "pos y=";camera position y() print "pos z=";camera position z() remend cpy#=GET GROUND HEIGHT(2,camera position x(),camera position z()) if cpy#<10.0 then position camera camera position x(),cpy#+10.0,camera position z() sync loop ` MAIN LOOP &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& show mouse end SET_TILES_MTX2: FILL MATRIX 2, 0, 13 ` make green x=39 : y=3 SET MATRIX HEIGHT 2, x, y+3, 1.5 set matrix height 2,x+1,y+3,2.75 set matrix height 2,x,y+4,2.5 set matrix height 2,x,y+5,1.5 set matrix height 2,x+1,y+4,4.0 set matrix height 2,x+1,y+2,1.5 set matrix height 2,x+2,y+2,2.75 set matrix height 2,x+2,y+3,4.0 set matrix height 2,x+1,y+3,4.0 set matrix height 2,x+2,y+3,4.0 set matrix height 2,x+1,y+4,4.0 set matrix height 2,x+2,y+4,4.0 set matrix height 2,x+2,y+2,2.75 set matrix height 2,x+3,y+2,2.75 set matrix height 2,x+2,y+3,4.0 set matrix height 2,x+3,y+3,4.0 set matrix height 2,x+3,y+4,2.75 set matrix height 2,x+2,y+5,4.0 set matrix height 2,x+3,y+5,4.0 set matrix height 2,x+3,y+2,2.75 set matrix height 2,x+4,y+2,2.75 set matrix height 2,x+3,y+3,4.0 set matrix height 2,x+4,y+3,4.0 set matrix height 2,x+3,y+4,4.0 set matrix height 2,x+4,y+4,4.0 set matrix height 2,x+3,y+5,4.0 set matrix height 2,x+4,y+5,4.0 set matrix height 2,x+3,y+5,4.0 set matrix height 2,x+4,y+5,4.0 set matrix height 2,x+5,y+2,1.5 set matrix height 2,x+5,y+3,1.5 set matrix height 2,x+5,y+4,1.5 set matrix tile 2,x,y+4,8 set matrix tile 2,x,y+2,12 set matrix tile 2,x,y+3,1 set matrix tile 2,x+1,y+4,1 set matrix tile 2,x+1,y+2,1 set matrix tile 2,x+2,y+2,1 set matrix tile 2,x+1,y+3,1 set matrix tile 2, x+2,y+3,1 set matrix tile 2,x+2,y+4,1 set matrix tile 2,x+3,y+2,1 set matrix tile 2,x+3,y+3,1 set matrix tile 2,x+3,y+4,1 set matrix tile 2,x+3,y+4,1 set matrix tile 2,x+4,y+2,9 set matrix tile 2,x+4,y+3,1 set matrix tile 2,x+4,y+4,11 ` make men's tee set matrix height 2,1,7,3.0 set matrix height 2,1,8,3.0 set matrix height 2,2,7,3.0 set matrix height 2,2,8,3.0 set matrix height 2,3,7,2.0 set matrix height 2,3,8,2.0 set matrix height 2,1,9,3.0 set matrix height 2,2,9,3.0 set matrix height 2,3,9,2.0 set matrix tile 2,1,8,1 set matrix tile 2,1,7,1 set matrix tile 2,2,8,1 set matrix tile 2,2,7,1 ` make ladies' tee set matrix tile 2,11,12,1 set matrix tile 2,12,12,1 set matrix tile 2,11,11,1 set matrix tile 2,12,11,1 ` place rough for i = 0 to 59 for t = 16 to 19 set matrix tile 2,i,t,2 next t next i for i=0 to 6 for t=11 to 15 set matrix tile 2,i,t,2 next t next i for i=48 to 59 for t=0 to 15 set matrix tile 2,i,t,2 next t next i for i = 0 to 59 for t = 0 to 3 set matrix tile 2,i,t,2 next t next i for i=10 to 23 for t=4 to 5 set matrix tile 2,i,t,2 next t next i ` sand trap ` left side of the green set matrix height 2,38,8,-5.0 set matrix height 2,38,7,-5.0 set matrix height 2,39,9,-5.0 set matrix tile 2,37,8,3 set matrix tile 2,38,9,3 set matrix tile 2,38,8,3 set matrix tile 2,39,9,3 set matrix tile 2,37,9,20 set matrix tile 2,39,8,15 set matrix tile 2,37,7,3 set matrix tile 2,38,7,15 ` hand place tiles to make the transition smoother restore left_fairway read total_tiles for t=1 to total_tiles read x,y,tile set matrix tile 2,x,y,tile next t restore behind_green read total_tiles for t=1 to total_tiles read x,y,tile set matrix tile 2,x,y,tile next t restore right_fairway read total_tiles for t=1 to total_tiles read x,y,tile set matrix tile 2,x,y,tile next t ` water for i= 38 to 41 for t=2 to 3 set matrix tile 2,i,t,4 next t next i restore water read total_tiles for t=1 to total_tiles read x,y,tile set matrix tile 2,x,y,tile next t left_fairway: ` # of entries data 15 ` x,y,tile # data 7,15,2,7,14,2,7,13,2,7,12,2,7,11,6 data 8,15,2,8,14,2,8,13,2,8,12,6 data 9,15,2,9,14,2,9,13,6 data 10,15,2,10,14,6 data 11,15,6 behind_green: ` # of entries data 8 ` x,y,tile # data 43,3,13,43,2,13 data 44,3,13,44,2,19 data 45,3,19 data 46,4,19 data 47,5,19,47,4,2 right_fairway: ` # of entries data 6 ` x,y,tile # data 8,4,19 data 9,5,19,9,4,2 data 24,5,18,24,4,2 data 25,4,18 update matrix 2 return water: ` # of entries data 30 ` x,y,tile # data 30,19,4,30,18,4,30,17,4,30,16,4,30,15,4,30,14,4,30,13,4,30,12,23 data 31,12,22,31,11,23 data 32,11,22,32,10,23 data 33,10,22,33,9,23 data 34,9,22,34,8,4,34,7,4,34,6,4,34,5,23 data 35,6,22,35,5,4 data 36,5,4,36,4,23 data 37,5,22,37,4,4,37,3,24 data 38,4,22,38,2,24 data 42,2,21 data 42,3,22 MAKE_TEXTURES: ` fairway grass ink rgb(0,192,43),0 box 128,128,191,191 : ` 13 for i=1 to 1800 ink rgb(0,rnd(40)+155,rnd(23)+20),0 dot rnd(63)+128,rnd(63)+128 next i get image 63,128,128,192,192 restore FG_PASTE_DATA for i=1 to 15 read x,y paste image 63,x,y next i FG_PASTE_DATA: ` 6,7,8,9,11,12,15,16,17,18,19,20 data 0,64,64,64,128,64,192,64,0,128,64,128,256,128,0,192,64,192,128,192,192,192,256,192 ` 21, 22, 23 data 0,256,64,256,128,256 ` lite grass - green ink rgb(0,215,0),0 box 0,0,63,63 : ` 1 is the loneliest for i=1 to 1750 ink rgb(0,rnd(20)+200,0),0 dot rnd(63),rnd(63) next i ink rgb(0,215,0),0 for t=0 to 63 line 128+t,127-t,191,127-t : ` bottom right half of 8 line 192+t,64,192+t,127-t : ` upper left half of 9 line 64+t,128+t,127,128+t : ` upper right half of 12 line 0,128+t,t,128+t : ` lower left 11 next t ` texture upper left half of 8 for i=1 to 850 ink rgb(0,rnd(20)+200,0),0 okay=0 repeat x=rnd(63) : y=rnd(63) if y+x>63 then okay=1 until okay=1 dot x+128,y+64 next i ` texture upper left half of 9 for i=1 to 850 ink rgb(0,rnd(20)+200,0),0 okay=0 repeat x=rnd(63) : y=rnd(63) if y+x<63 then okay=1 until okay=1 dot x+192,y+64 next i ` texture lower left half on 11 for i=1 to 850 ink rgb(0,rnd(20)+200,0),0 okay=0 repeat x=rnd(63) : y=rnd(63) if y>x then okay=1 until okay=1 dot x,y+128 next i ` texture upper right half of 12 for i=1 to 850 ink rgb(0,rnd(20)+200,0),0 okay=0 repeat x=rnd(63) : y=rnd(63) if y<x then okay=1 until okay=1 dot x+64,y+128 next i ` rough ink rgb(0,128,0),0 `box 0,192,31,255 : ` fill 16 box 64,0,127,63 : ` 2 for i=1 to 1750 ink rgb(rnd(10),rnd(20)+110,rnd(10)),0 : ` fix 2 dot rnd(63)+64,rnd(63) next i ink rgb(0,128,0),0 box 96,192,127,255 : ` right half of 17 box 192,256,255,319 : ` fill 24 for t=0 to 63 line 128,192+t,128+t,192+t : ` lower left 18 line 192+t,255-t,255,255-t : ` lower right 19 line 0,64+t,63-t,64+t : ` upper left 6 line 64+t,64+t,127,64+t : ` upper right 7 line 256,t,319-int(t/2),t : ` upper left 5 line 256,64+t,287-int(t/2),64+t : ` upper left 10 next t ` texture rough on 6 for i=1 to 850 ink rgb(rnd(10),rnd(20)+110,rnd(10)),0 okay=0 repeat x=rnd(63) : y=rnd(63) if y+x<63 then okay=1 until okay=1 dot x,y+64 next i ` texture rough on 19 for i=1 to 850 ink rgb(rnd(10),rnd(20)+110,rnd(10)),0 okay=0 repeat x=rnd(63) : y=rnd(63) if y+x>63 then okay=1 until okay=1 dot x+192,y+192 next i ` I tried to texture the rough on image texture #18, but DBC wouldn't let me! ` It turns the entire screen blue and looks awful `texture rough on 18 `for i=1 to 850 ` okay=0 ` repeat ` x=rnd(63) : y=rnd(63) ` if y<x then okay=1 ` until okay=1 ` ink rgb(rnd(10),rnd(20)+110,rnd(10)),0 ` dot (x+128),(y+192) `next i ` really dark green ink rgb(0,96,0),0 box 192,128,255,191 : ` 14 ` sand ink rgb(255,255,128),0 box 128,0,191,63 : ` 3 for i=1 to 2350 ink rgb(rnd(10)+245,rnd(10)+245,rnd(20)+108),0 dot rnd(63)+128,rnd(63) next i ink rgb(255,255,128),0 for t=0 to 63 line 256+t,128,256+t,191-t : ` upper left 15 line 256+t,255-t,319,255-t : ` lower right 20 next t ` texture upper left on 15 for i=1 to 850 ink rgb(rnd(10)+245,rnd(10)+245,rnd(20)+108),0 okay=0 repeat x=rnd(63) : y=rnd(63) if y+x<63 then okay=1 until okay=1 dot x+256,y+128 next i ` texture lower right half of 20 for i=1 to 850 ink rgb(rnd(10)+245,rnd(10)+245,rnd(20)+108),0 okay=0 repeat x=rnd(63) : y=rnd(63) if y+x>63 then okay=1 until okay=1 dot x+256,y+192 next i ` water ink rgb(0,64,190),0 box 192,0,255,63 : ` 4 for t=0 to 63 line 192+t,256+t,255,256+t : ` upper right 24 line 128+t,256+t,191,256+t : ` upper right 23 line 0,319-t,t,319-t : ` upper left 21 line 64,319-t,127-t,319-t : ` lower left 22 next t ` texture lower left on 24 for i=1 to 850 ink rgb(rnd(10),rnd(20)+110,rnd(10)),0 okay=0 repeat x=rnd(63) : y=rnd(63) if y>x then okay=1 until okay=1 dot x+192,y+256 next i get image 1,0,0,320,320 PREPARE MATRIX TEXTURE 2, 1, 5, 5 `backdrop off `sync `wait key ` make flag cls ink rgb(200,43,28),0 box 0,0,24,24 ink rgb(255,255,255),0 set text size 14 text 10,2,"1" get image 100,0,0,24,24 ` flagstick cls ink rgb(255,255,255),0 box 0,0,1,1 box 0,4,1,5 box 0,8,1,9 ink rgb(220,0,0),0 box 0,2,1,3 box 0,6,1,7 box 0,10,1,11 get image 101,0,0,2,12 ` sign cls ink rgb(128,64,0),0 box 0,0,255,155 ink rgb(255,255,94),0 box 10,10,245,145 ink rgb(225,225,225),0 box 11,11,244,82 ink rgb(94,255,255),0 box 11,21,244,72 set text size 36 set text font "Tahoma" ink rgb(0,200,45),0 text 30,25,"Hole #1 Par 4" set text size 28 ink rgb(255,0,0),0 box 15,98,22,105 ink rgb(0,0,199),0 box 15,128,22,135 ink rgb(26,97,220),0 text 27,86,"338 Yards" text 27,116,"422 Yards" set text size 11 text 235,135,"LB" get image 102,0,0,256,156 return MAKE_UNDULATIONS: for count=1 to 44 xrnd=rnd(11)+16 yrnd=rnd(11)+4 if count>30 then xrnd=rnd(7)+47 rhgt#=((rnd(50)+40)/10) if rnd(100)>10 then rhgt#=0-rhgt# mhgt#=rhgt#/2 lhgt#=rhgt#/2 for i=(xrnd-3) to (xrnd+3) set matrix height 2,i,(yrnd-3),lhgt# set matrix height 2,i,(yrnd+3),lhgt# next i for i=(yrnd-3) to (yrnd+3) set matrix height 2,xrnd-3,i,lhgt# set matrix height 2,xrnd+3,i,lhgt# next i for i=(xrnd-2) to (xrnd+2) set matrix height 2,i,yrnd-2,mhgt# set matrix height 2,i,yrnd+2,mhgt# next i for i=(yrnd-2) to (yrnd+2) set matrix height 2,xrnd-2,i,mhgt# set matrix height 2,xrnd+2,i,mhgt# next i for t=(yrnd-1) to (yrnd+1) for i=(xrnd-1) to (xrnd+1) set matrix height 2,i,t,rhgt# next i next t next count update matrix 2 return Rem ************************************************** Rem Smooth Matrix - Thanks to TDK Rem ************************************************** Smooth: Rem Averages matrix heights to remove jagged edges For Z=0 to TilesZ For X=0 to TilesX P0#=Get Matrix Height(2,X,Z): Rem Current point height Rem Get 4 adjoining points heights (if they exist) If Z-1 > 0 P1#=Get Matrix Height(2,X,Z-1) Else P1#=P0# Endif If X+1 < TilesX P2#=Get Matrix Height(2,X+1,Z) Else P2#=P0# Endif If Z+1 < TilesZ P3#=Get Matrix Height(2,X,Z+1) Else P3#=P0# Endif If X-1 > 0 P4#=Get Matrix Height(2,X-1,Z) Else P4#=P0# Endif Average#=(P0#+P1#+P2#+P3#+P4#)/5: Rem Av height of other points Set Matrix Height 2,x,z,Average# MHeight#(X,Z)=Average# Next x Next z Return Normalise: Rem By Lee Bamber From DB Example - Adds shaded areas to matrix to give depth For z=1 to 20 For x=1 to 60 h8#=MHeight#(X,Z-1) h4#=MHeight#(X-1,Z) h#=MHeight#(X,Z) h2#=MHeight#(X,Z) x1#=(x-1)*25.0 y1#=h# x2#=(x+0)*25.0 y2#=h4# dx#=x2#-x1# dy#=y2#-y1# ax#=atanfull(dx#,dy#) ax#=wrapvalue(90-ax#) z1#=(z-1)*25.0 y1#=h2# z2#=(z+0)*25.0 y2#=h8# dz#=z2#-z1# dy#=y2#-y1# az#=atanfull(dz#,dy#) az#=wrapvalue(90-az#) nx#=sin(ax#) ny#=cos(ax#) nz#=sin(az#) Set matrix normal 2,x,z,nx#,ny#,nz# next x next z Update Matrix 2 return