rem **Wooden Hut** rem CR 2007 rem **Setup** gosub setup_screen: gosub setup_variables: gosub make_objects: gosub texture_objects: point camera 0,0,0 rem **Main Loop** do inc fire_loop gosub animate_smoke: if fire_loop=2 then gosub animate_fire: gosub move_camera: sync loop rem **Subroutines** setup_screen: set display mode 800,600,32 cls autocam off sync on position camera -300,0,-200 point camera -300,100,-200 set camera range 1,10000 return setup_variables: rem dim carpet arrays csize=128 dim carpet(csize,csize) dim oldcarpet(csize,csize) return make_objects: rem make house outside make object cylinder 1,100 scale object 1,100,50,200 set object 1,1,0,1 rem make roof for a=2 to 4 make object sphere a,120+a scale object a,100,100,200 set object a,1,0,1 next a rem make chimney make object cylinder 5,20 position object 5,0,30,50 scale object 5,75,350,75 rem make ground make object plain 6,2000,2000 position object 6,0,-26,0 rotate object 6,90,0,0 color object 6,rgb(10,20,0) rem make smoke make object plain 7,20,50 position object 7,0,75,42+a ghost object on 7 rem make bush for a=8 to 20 make object sphere a,a+5 set object a,1,0,1 position object a,-55,-25,50 next a for a=8 to 20 make object sphere a+13,a+5 set object a+13,1,0,1 position object a+13,-55,-25,-50 next a rem make house inside make object cylinder 34,-100 scale object 34,100,50,200 set object 34,1,0,1 rem make carpet make object plain 35,40,60 rotate object 35,90,0,30 position object 35,0,-23,-30 rem make fireplace make object box 36,5,30,30 position object 36,-15,-15,50 make object box 37,5,30,30 position object 37,15,-15,50 make object box 38,30,30,5 position object 38,0,-15,65 rem make fire for a=39 to 44 make object triangle a,rnd(10)-5,rnd(30)-20,40+rnd(10),rnd(10)-5,rnd(30)-20,40,rnd(10)-5,rnd(30)-20,40+rnd(10) set object a,1,1,0 next a rem make logs for a=45 to 48 make object box a,4,4,rnd(5)+15 rotate object a,rnd(10),rnd(360),rnd(90) position object a,0,-23,50 next a rem make fire place floor make object box 49,30,5,30 position object 49,0,-25,50 rem make sky make object sphere 50,-9000 set object 50,1,1,1,1,0,0 rem make floorboards make object plain 51,40,20 rotate object 51,90,0,0 position object 51,-25,-25,50 make object plain 52,60,20 rotate object 52,90,0,0 position object 52,-15,25,50 rem make picture make object plain 53,15,10 position object 53,0,5,-90 rotate object 53,0,180,0 rem setup backdrop and lights and fog fog on fog color rgb(5,5,5) fog distance 1000 color backdrop rgb(0,0,0) make light 1 position light 1,0,0,40 set spot light 1,90,180 point light 1,0,0,0 set ambient light 25 return texture_objects: rem make bitmaps create bitmap 1,256,256 create bitmap 2,16,32 rem texture building set current bitmap 1 cls rgb(50,50,0) ink rgb(40,40,0),0 for x=0 to 256 step 32 for y=0 to 256 step 64 line x,y,x,y+64 line x,y,x+64,y next y next x ink rgb(0,0,0),0 for x=59 to 69 for y=100 to 256 dot x,y next y next x get image 1,0,0,256,256 flip bitmap 1 mirror bitmap 1 get image 34,0,0,256,256 texture object 1,1 texture object 34,34 rem texture roof for a=2 to 4 cls rgb(0,0,0) for x=0 to 256 for y=0 to 100 step a-1 ink rgb(80+rnd(30),60+rnd(40),0),0 line x,y,x,y+rnd(1+3*a) next y next x blur bitmap 1,1 get image a,0,0,256,256 texture object a,a set object a,1,0,0 if a>2 then ghost object on a next a rem texture chimney cls rgb(70,70,70) get image 5,0,0,2,2 texture object 5,5 rem texture bush cls rgb(0,0,0) ink rgb(0,50,0),0 for b=20 to 8 step -1 for a=0 to 800 dot rnd(128),rnd(128) next a ink rgb(0,75,0),0 for a=0 to 800 dot rnd(128),rnd(128) next a get image b,0,0,128,128 next b for a=8 to 20 texture object a,a next a for a=8 to 20 texture object a+13,a next a rem texture carpet for a=0 to 200 for x=2 to csize-2 for y=2 to csize-2 sum=oldcarpet(x-1,y)+oldcarpet(x+1,y)+oldcarpet(x,y-1)+oldcarpet(x,y+1) if sum>0 and sum<4 then carpet(x,y)=0 if sum=0 or sum=4 then carpet(x,y)=1 next y next x for x=1 to csize-1 for y=1 to csize-1 oldcarpet(x,y)=carpet(x,y) next y next x next a cls rgb(50,0,0) for x=0 to csize for y=0 to csize if x>csize-(csize/10) or x<csize/10 then border=1 if y>csize-(csize/10) or y<csize/10 then border=1 if border=1 then ink rgb(0,0,50),0 else ink rgb(0,20,0),0 border=0 if carpet(x,y)=1 then dot x,y next y next x get image 35,0,0,csize,csize texture object 35,35 rem texture fireplace cls rgb(70,70,70) get image 36,0,0,1,1 texture object 36,36 texture object 37,36 texture object 38,36 texture object 49,36 rem texture logs cls rgb(20,20,0) get image 45,0,0,2,2 for a=45 to 48 texture object a,45 next a rem texture sky cls rgb(0,0,0) ink rgb(200,200,200),0 for a=0 to 25 dot rnd(128),rnd(128) next a get image 50,0,0,128,128 texture object 50,50 scale object texture 50,10,10 rem texture floorboard cls rgb(50,50,0) get image 51,0,0,2,2 texture object 51,51 cls rgb(15,15,0) get image 52,0,0,2,2 texture object 52,52 rem texture picture cls rgb(100,75,0) text 5,5,"Home Sweet" text 25,20,"Home" get image 53,0,0,95,45 texture object 53,53 set current bitmap 0 return animate_smoke: inc rise,3 set current bitmap 2 cls rgb(0,0,0) ink rgb(100,100,100),0 for x=0 to 16 for y=0 to 32 smoke_angle#=(18*y)+rise smoke=100*sin(smoke_angle#)+25*ABS(cos(2*smoke_angle#))+50*cos(4*smoke_angle#)+55*sin(smoke_angle#)^2 dec smoke, ABS(8-x)*20 dec smoke, (32-y)*5 if smoke<0 then smoke=0 if smoke>255 then smoke=255 ink rgb(smoke,smoke,smoke),0 dot x,y next y next x get image 7,0,0,16,32 texture object 7,7 point object 7,camera position x(),object position y(7),camera position z() return animate_fire: fire_loop=0 color light 1,rgb(rnd(100)+155,rnd(150),0) set current bitmap 1 rem texture fire for a=39 to 44 cls rgb(rnd(100)+155,rnd(150),0) get image a,0,0,2,2 texture object a,a scale object a,125-rnd(50),150-rnd(100),125-rnd(50) position object a,rnd(10)-5,-17,rnd(4)+2 next a set current bitmap 0 return hide_bush: for a=8 to 33 hide object a next a return show_bush: for a=8 to 33 show object a next a return move_camera: if camera position x()>0 then gosub hide_bush: if object visible(8)=0 and camera position x()<0 then gosub show_bush: if leftkey()=1 or mousex()<screen width()/10 then yrotate camera wrapvalue(camera angle y()-3) if rightkey()=1 or mousex()>screen width()-screen width()/10 then yrotate camera wrapvalue(camera angle y()+3) if upkey()=1 then move camera 4 if downkey()=1 then move camera -4 if mousey()>screen height()-screen height()/10 and wrapvalue(camera angle x()+90)<170 then xrotate camera wrapvalue(camera angle x()+2) if mousey()<screen height()/10 and wrapvalue(camera angle x()+90)>0 then xrotate camera wrapvalue(camera angle x()-2) position camera camera position x(),0,camera position z() rem move earth and sky position object 50,camera position x(),camera position y(), camera position z() position object 6,camera position x(),camera position y()-26, camera position z() return