Motion and Collision by thechew14th Mar 2006 12:07
|
---|
Summary A simple collision detection. Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com function Move(numEn) cu=numEn+3 ox#=Object Position x(2) oz#=Object Position z(2) oy#=Object Position y(2) clone object cu,2 position object cu,ox#,oy#,oz# if leftkey()=1 move object left cu,0.1 turn object left cu,0.1 nx#=Object Position x(cu) nz#=Object Position z(cu) ny#=object size y(1)*10 np# = intersect object(1,ox#,oy#,oz#,nx#,ny#,nz#) if np#>0 move object left 2,0.1 turn object left 2,0.1 turn camera left 1,0.1 endif endif if rightkey()=1 move object right cu,0.1 turn object right cu,0.1 nx#=Object Position x(cu) nz#=Object Position z(cu) ny#=object size y(1)*10 np# = intersect object(1,ox#,oy#,oz#,nx#,ny#,nz#) if np#>0 move object right 2,0.1 turn object right 2,0.1 turn camera right 1,0.1 endif endif if upkey()=1 move object cu,0.1 nx#=Object Position x(cu) nz#=Object Position z(cu) ny#=object size y(1)*10 np# = intersect object(1,ox#,oy#,oz#,nx#,ny#,nz#) if np#>0 move object 2,0.1 move camera 1,0.1 endif endif if downkey()=1 move object cu,-0.1 nx#=Object Position x(cu) nz#=Object Position z(cu) ny#=object size y(1)*10 np# = intersect object(1,ox#,oy#,oz#,nx#,ny#,nz#) if np#>0 move object 2,-0.1 move camera 1,-0.1 endif endif delete object cu endfunction |