3d platform example by HomerS3rd May 2013 19:50
|
---|
Summary 3d platform example, models made with dbc Description just load it in your compiler. make this is an example for beginners in dbc. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com rem set display mode 1024,768,32 sync on hide mouse playergrav#=1.5 rem make images for the face. ink rgb(0,255,0),rgb(1,1,1) box 0,0,256,256 ink rgb(0,100,0),rgb(1,1,1) box 0,0,128,128 ink rgb(0,100,0),rgb(1,1,1) box 128,128,256,256 get image 1,0,0,256,256 for t=1 to 257 ink rgb(200,125,t-1),rgb(1,1,1) line 0,t-1,256,t-1 next t rem black pupil eyes ink rgb(10,10,10),rgb(1,1,1) for d=1 to 4 circle 115,100,d-1 circle 135,100,d-1 next d rem white eyes ink rgb(250,250,250),rgb(1,1,1) for d=5 to 8 circle 115,100,d circle 135,100,d next d get image 2,0,0,256,256 rem matrix for background fun and floor= object 200 MAKE_MATRIX() make object box 200,500,2,500 position object 200,0,-6,0 color object 200,rgb(30,150,30) make object collision box 200,-250,-1,-250,250,1,250,0 rem make 10 boxes for n = 1 to 10 make object cube n,10 position object n,n*15,(n-1)*10,0 make object collision box n,-5,-5,-5,5,5,5,0 m#=n color object n,rgb(m#*25.5,0,0) set object n,1,1,1,1,1,1,1 next n rem make top platform make object box 11,20,10,1000 position object 11,11*15,(11-1)*10,-100 make object collision box 11,-10,-5,-500,10,5,500,0 color object 11,rgb(200,0,0) ghost object on 11 rem make backwall not to fall of the blocks make object box 1000,100,100,10 make object collision box 1000,-50,-50,-5,50,50,5,0 position object 1000,50,0,10 color object 1000,rgb(100,100,200) ghost object on 1000 rem make head make object sphere 100,10 position object 100,-30,20,0 make object collision box 100,-5,-5,-5,5,5,5,0 texture object 100,2 delete image 2 yrotate object 100,180 fix object pivot 100 yrotate object 100,90 rem make the head to collide record the xyz values of the head set object collision on 100 x#=object position x(100) y#=object position y(100) z#=object position z(100) rem set the camera to follow, you can change the values position camera x#,y#+10,z#-75 point camera x#,y#,z# rem color backdrop to a blue sky color backdrop rgb(100,150,230) ink rgb(255,255,255),0 set global collision on rem main loop repeat oldx#=object position x(100) oldy#=object position y(100) oldz#=object position z(100) rem keep the mainloop small with GOSUB GOSUB controls x#=object position x(100) y#=object position y(100) z#=object position z(100) playergrav#=playergrav#-0.1 y#=y#+playergrav# if y#>-10 text 0,0,"height: "+str$(y#) else text 0,0,"AAAAHHHHHHHHHHHHHHH!!!!!!!!!!!!!!!!!!!!!!!" endif if object collision(100,0)>0 dec x#, get object collision x() dec y#, get object collision y() dec z#, get object collision z() playergrav#=0.0 endif position object 100,x#,y#,z# position camera x#,y#+20,z#-75 sync until returnkey()=1 rem delete objects after playing for n=1 to 10 delete object n next n delete object 100 delete object 200 delete object 1000 end function MAKE_MATRIX() make matrix 1,10000,10000,10,10 position matrix 1,-250,-10,-250 prepare matrix texture 1,1,8,8 fill matrix 1,0,1 delete image 1 set matrix 1,1,1,1,1,1,1,1 endfunction controls: if spacekey() and playergrav#=0.0 THEN playergrav#=1.5 IF upkey() move object 100,2 endif IF downkey() move object 100,-2 endif IF leftkey() yrotate object 100, wrapvalue(object angle y(100)-8) endif IF rightkey() yrotate object 100, wrapvalue(object angle y(100)+8) endif RETURN |