_______TOP_______: rem Generic Template rem Player = object 10 rem Cubes = objects 100-120 _____INITIALIZE_____: set display mode 1920,1080,32 SYNC ON SYNC RATE 60 backdrop on color backdrop rgb(10,100,100) autocam off set global collision off global check1#,check2#,x#,z#,oldx#,oldz#,s#,h# x#=1000.0:z#=1000.0:a#=0.0:s#=0.0:h#=0.0 cx#=0.0:cy#=0.0:cz#=0.0:ca#=0.0:camght=50 camrot=0:camdist=0:camlen=0:pdist#=0 gosub Setupland1 gosub makeplayer gosub makeobjects gosub ambient gosub resetcam _____DO_LOOP_____: do if x#<100 then x#=100 if z#<100 then z#=100 if x#>landsize-100 then x#=landsize-100 if z#>landsize-100 then z#=landsize-100 oldx#=x#:oldz#=z# if inkey$()="e" then sync rate 0 if inkey$()="E" then sync rate 60 gosub printdata gosub camera_controls gosub update_camera gosub Playercontrol gosub checkcollision SYNC loop rem -------------ROUTINES-------------------- ____SET_SCENERY___: Setupland1: rem ground textures rem create texture cls rgb(0,100,20) inkcolor#=rgb(255,255,255) line 0,0,0,250 line 1,1,1,250 line 2,2,2,250 line 0,0,250,0 line 1,1,250,1 line 2,2,250,2 line 0,0,250,250 line 0,250,250,0 rem next n get image 2,0,0,250,250 rem Make landscape landsize=4000:grid=30:mtxrandomize=1 make matrix 1,landsize,landsize,grid,grid set matrix 1,1,0,0,1,1,1,1 prepare matrix texture 1,2,1,1 randomize matrix 1,mtxrandomize rem *********** rem get ground done update matrix 1 return _____CONTROL_PLAYER___: Playercontrol: rem ---- Control Character ---- x#=newxvalue(x#,a#,s#) z#=newzvalue(z#,a#,s#) h#=get ground height(1,x#,z#) position object 10,x#,h#+1,z# yrotate object 10,a# if upkey()=1 and s#<8.0 then s#=s#+0.1 if downkey()=1 and s#>-6.0 then s#=s#-0.1 if leftkey()=1 then a#=wrapvalue(a#-1) if rightkey()=1 then a#=wrapvalue(a#+1) if inkey$()="s" then s#=0.0 return ______CAMERA_ROUTINES____: rem -------CAMERA-------- camera_controls: if inkey$()="z" then camdist=camdist+0.2 if inkey$()="Z" then camdist=camdist-0.2 if inkey$()="x" then camhgt=camhgt+2 if inkey$()="X" then camhgt=camhgt-2 if inkey$()="c" then camrot=wrapvalue(camrot+0.2) if inkey$()="C" then camrot=wrapvalue(camrot-0.2) if inkey$()="v" then camlen=camlen+0.2 if inkey$()="V" then camlen=camlen-0.2 if inkey$()="b" then camrot = 180 if inkey$()="B" then camrot = 0 if inkey$()="n" then camdist=50:camlen=0:camrot=180:camhgt=80:camflag=0:set camera range 20,20000:wait 1 if inkey$()="N" then camdist=80:camlen=0:camrot=0:camhgt=80:camflag=1:set camera range 20,20000:wait 1 if inkey$()=">" then gosub Resetcam if inkey$()="m" then camdist=-1000:camhgt=500:camrot=0:set camera range 100,20000 if inkey$()="M" then camdist=-3000:camhgt=1000:camrot=0:set camera range 100,20000 return rem camera update update_camera: rem Position camera to the back of the character ca#=wrapvalue(a#+camrot) cx#=newxvalue(x#,ca#,camdist) cz#=newzvalue(z#,ca#,camdist) cy#=h# position camera cx#,cy#+camhgt,cz# rem Point camera at object point camera x#,h#+camhgt+camlen,z# return rem camera reset Resetcam: set camera range 1,20000 camdist=-100 camhgt=50 camrot=0 camlen=0 return _____PRINT_ON__SCREEN___: printdata: set cursor 0,0 print "Polys=",statistic(1) print "FPS=",screen fps() print "player x#= ",x# print "player h#= ",h# print "player z#= ",z# print "player angle a#= ",a# print "speed s#= ",s# print "intersect value check1#=",check1# print "intersect value check2#=",check2# print print " press s to stop" return _____CHECK_ROUTINES_____: checkcollision: rem cubes position x1#=object position x(100):z1#=object position z(100) x2#=object position x(101):z2#=object position z(101) rem player position px#=object position x(10):pz#=object position z(10) rem check distance to cubes check1#=intersect object(100,px#,50,pz#,x1#,50,z1#) check2#=intersect object(101,px#,50,pz#,x2#,50,z2#) if check1#<5 or check2#<5 then s#=0:x#=oldx#:z#=oldz# return ____MAKE_OBJECTS____: rem -------------Characters-Objects------------ makeplayer: make object cube 10,3 scale object 10,100,200,100 return makeobjects: cubesize=100 for n=100 to 101 make object cube n,cubesize set object n,1,1,0,1,1,1 next n position object 100,x#+200,cubesize/2,1000 position object 101,x#-200,cubesize/2,1000 return rem ------------------ambient---------------- _______AMBIENT_______: ambient: set ambient light 70 set directional light 0,0.1,0.2,0.25 position light 0,0.0,2000.0,0.0 point light 0,4000,0,4000 fog on fog color rgb(150,150,200) fog distance 10000 return end