3 by Flaming Ghost16th Feb 2005 20:16
|
---|
Summary A 3-D moudle that walks on a Matrix Description I am a new programmer, this is something I learned how to do over much trial and error, and a few tutorials. It's an x file man, who walks over a basic Matrix,while the camera follows him. YOu need the media files, and you need to unzip them for it to work, sorry. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `Set Up Game Sync On Sync Rate 30 `Prepare the grass texture for the Matrix Load bitmap "grass09.bmp",1 Get Image 1,0,0,128,128 Delete Bitmap 1 `Create Ground Make Matrix 1,10000,10000,15,15 Prepare Matrix Texture 1,1,1,1 `Load Charecter load object "idle.x",1 : append object "walk.x",1,100 yrotate object 1,180 : fix object pivot 1 position object 1,10000,0,10000 loop object 1,0,20 : set object speed 1,5 `Main Game Loop do `Variables aY# = Object angle Y(1) stage=0 `Player Movement IF Leftkey()=1 then a#=a#-9.0 : a#=wrapvalue(aY#-4.5) IF Rightkey()=1 then a#=a#+9.0 : a#=wrapvalue(aY#+4.5) If Upkey()=1 then x#=NewxValue(x#,a#,+12) : z#=NewzValue(z#,a#,+12) : stage=1 IF Downkey()=1 then x#=NewxValue(x#,a#,-12) : z#=NewzValue(z#,a#,-12) : stage=1 `Controling Player Animation IF stage<>oldstage IF stage=0 set object frame 1,0.0 loop object 1,0,20 set object speed 1,10 Endif IF stage=1 set object frame 1,105.0 loop object 1,105,125 set object speed 1,40 Endif oldstage=stage Endif `Camera Control cZ# = Newzvalue(Z#,aY#-180,300) cX# = Newxvalue(X#,aY#-180,300) Position Camera cX#,200,cZ# Point camera X#,150,Z# `More Movement position object 1,x#,0.0,z# yrotate object 1,a# `Refresh Screen sync `End MAin Game Loop loop |