need a little help curving the road by pollywog1st Dec 2008 21:55
|
---|
Summary just started messing around trying to set up a racing game. I pulled most of the media in from the road terrain demo so if you did an odd install you may need to change the path fo Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com Rem Project: motorcycle Rem Created: 11/28/2008 6:22:48 PM Rem ***** Main Source File ***** #CONSTANT motorcycle 1 #CONSTANT motorcyleshadow 2 #CONSTANT shadowimage 2 #CONSTANT grasssimage 3 #CONSTANT roadimage 4 rem Create shadow for bike make object plain motorcyleshadow,256,256 load image "C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\RoadTerrain\media\bike\shadow.bmp",shadowimage scale object motorcyleshadow,15,15,15 texture object motorcyleshadow,shadowimage xrotate object motorcyleshadow,90 ghost object on motorcyleshadow,1 set object light motorcyleshadow,0 for c = 1 to 2 if c = 1 width = 2000 else width = 50 endif make matrix c,width,9000,20,90 height# = 1 down# = 1 for x = 0 to 90 if x > 20 and x < 40 then height# = height# * 1.35 if x > 40 then height# = height# - 20 if height# < 1 then height# = 1 for z = 0 to 20 set matrix height c,z,x,height# + c next z next x next c position matrix 1,-1000,0,0 position matrix 2,-25,0,0 `load image "media\grass.jpg",grasssimage load image "C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\RoadTerrain\media\world\road.jpg",roadimage `prepare matrix texture 1, grasssimage, 20, 90 prepare matrix texture 2, roadimage, 20, 90 tileno = 1 for z = 29 to 0 step -1 for x = 0 to 19 ` set matrix tile 1,x,z, tileno set matrix tile 2,x,z, tileno inc tileno next x next z update matrix 1 update matrix 2 rem Load bike load object "C:\Program Files\Dark Basic Software\Dark Basic Professional\Projects\RoadTerrain\media\bike\bike.x",motorcycle scale object motorcycle,1000,1000,1000 rotate object motorcycle,0,180,0 fix object pivot motorcycle rotate object motorcycle,0,0,0 set object light motorcycle,0 position camera 0,20,-45 point camera 0,20,0 do rem Rotate bike wheels heada#=wrapvalue(heada#+2) if limb exist(motorcycle,1)=1 and speed#>0 t=3 : rotate limb motorcycle,t,wrapvalue(limb angle x(motorcycle,t)-35),0,0 t=5 : rotate limb motorcycle,t,wrapvalue(limb angle x(motorcycle,t)-35),0,0 endif x = object position x(1) z = object position z(1) if z > 8000 then z = 2 y = get ground height (1,x,z) if upkey() speed# = speed# + .1 else speed# = speed# - .05 endif if speed# > 5 then speed# = 5 if speed# < 0 then speed# = 0 if rightkey() and object angle z (motorcycle) > -35 and speed#>0 roll object right 1,speed#/(10-angle) else if leftkey() and object angle z (motorcycle) < 35 and speed#>0 roll object left 1,speed#/(10-angle) endif endif if speed#>0 x = x - object angle z(1) /10 position object 1, x,y+2,z + speed# position object 2, x-object angle z(1)/10,y+5,z-7 + speed# endif position camera 0, x,y+20,z-50 point camera x,y,z set cursor 100,100 print object position z(1) loop end |