this was sorta a personal project that i was gona team up with you on, and the code is long. but here it is any way. link to media and .bb,.exe here: http://www.mediafire.com/?pnl1zl9tfxg
Graphics3D 1024,768,32 SetBuffer(BackBuffer()) AppTitle "mazegame" Type player Field ent,wep,cam,piv,hud Field ammo,health,speed# End Type Type turret Field tur,piv Field health End Type Global level,level_mesh,beam,beam_piv,beam_tex,frame=1,scale#=1 Global startx,startz,endx,endz Global cam_x#,cam_z#,cam_pitch#,cam_yaw#,cam_speed#=.5 ; Current Global dest_cam_x#,dest_cam_z#,dest_cam_pitch#,dest_cam_yaw# ; Destination Global ent_x#,ent_z#,ent_pitch#,ent_yaw#,ent_speed#=.5 ; Current Global dest_ent_x#,dest_ent_z#,dest_ent_pitch#,dest_ent_yaw# ; Destination Global playr=1,ground=2,enemy=3,bullet=4,endzone=5 Collisions playr,ground,2,2 Collisions playr,enemy,2,2 Collisions playr,endzone,2,2 Collisions bullet,enemy,2,1 Collisions bullet,ground,2,3 ;start game main_menu() run_game() credits() ;************************************** ;*FFFFF********************T*****S*S*S* ;*F*********************TTTTTTT**S***** ;*FFFFF*U**U*NN**N*CCCC****T******S**** ;*F*****U**U*N*N*N*C*******T*******S*** ;*F*****U**U*N**NN*C*******T*********S* ;*F******UU**N***N*CCCC****T*****S*S*S* ;************************************** Function main_menu() AutoMidHandle=True backdrop=LoadImage("media/images/backdrop.png") start=LoadImage("media/images/startbutton.png") rightarrow=LoadImage("media/images/arrowright.png") leftarrow=LoadImage("media/images/arrowleft.png") hard=LoadImage("media/images/hard.png") easy=LoadImage("media/images/easy.png") normal=LoadImage("media/images/normal.png") music=LoadSound("media/sound/right.mp3") LoopSound music active=1 ;menu loop chnl_music=PlaySound (music) Repeat Cls DrawImage backdrop,0,0 DrawImage rightarrow,810,720 DrawImage leftarrow,200,720 If KeyHit(203) active=active-1 If KeyHit(205) active=active+1 If active>3 active=1 If active<1 active=3 If active=1 diff=easy If active=2 diff=normal If active=3 diff=hard DrawImage diff,512,480 If KeyHit(28) level=active:load_level():StopChannel chnl_music:FreeSound music:Exit Flip Until KeyHit(1) ;End menu loop End Function Function load_level() music=LoadSound("media/sound/music.ogg");loads the main game music and plays it LoopSound music chnl_music=PlaySound (music) detail=LoadTexture("media/mazes/detail.png") ScaleTexture detail,8,8 ;TextureBlend detail,2 If level=1 level_mesh=LoadTerrain("media/mazes/maze01.png") tex=LoadTexture("media/mazes/maze1.png") sky_tex=LoadTexture("media/images/sky01.png") ScaleTexture tex,512,512 EntityTexture level_mesh,tex,0,1 EntityTexture level_mesh,detail,0,2 EntityType level_mesh,ground startx=35 startz=35 endx=506 endz=35 Else If level=2 level_mesh=LoadTerrain("media/mazes/maze02.png") tex=LoadTexture("media/mazes/maze2.png") sky_tex=LoadTexture("media/images/sky02.png") ScaleTexture tex,512,512 EntityTexture level_mesh,tex EntityTexture level_mesh,detail,0,2 EntityType level_mesh,ground startx=10 startz=400 endx=506 endz=35 Else If level=3 level_mesh=LoadTerrain("media/mazes/maze03.png") tex=LoadTexture("media/mazes/maze3.png") sky_tex=LoadTexture("media/images/sky01.png") ScaleTexture tex,512,512 EntityTexture level_mesh,tex EntityTexture level_mesh,detail,0,2 EntityType level_mesh,ground startx=90 startz=507 endx=506 endz=24 End If ScaleEntity level_mesh,1,10,1 TerrainDetail level_mesh,10000 TerrainShading level_mesh,True EntityPickMode level_mesh,1 skycube=CreateCube() ScaleEntity skycube,512,300,512 FlipMesh skycube EntityTexture skycube,sky_tex EntityOrder skycube,10 end_cube=CreateCylinder(32) PositionEntity end_cube,endx,30,endz ScaleEntity end_cube,10,30,10 etex=LoadTexture("media/images/exit.png") EntityTexture end_cube,etex EntityType end_cube,endzone ;turrets loading For k=1 To Rnd(10,25) Repeat tx#=Rnd(1,512)+1 tz#=Rnd(1,512)+1 ty#=TerrainY( level_mesh,tx,0,tz ) Until ty<1 t.turret=New turret t\piv=CreatePivot() RotateEntity t\piv,0,90,0 t\tur=LoadMD2("media/meshes/weapon1.md2",t\piv) tex=LoadTexture("media/meshes/weapon1.bmp") EntityTexture t\tur,tex ScaleEntity t\tur,0.1,0.1,0.1 EntityPickMode t\tur,1 EntityType t\tur,enemy PositionEntity t\piv,tx,ty,tz Next End Function Function run_game() load_player() While Not KeyHit(1) update_player() update_enemy() If KeyHit( 57 )=True Then enable=1-enable ; Enable/disable wireframe rendering WireFrame enable UpdateWorld() RenderWorld() Flip 1 Wend credits() End Function Function pause_game() PauseChannel chnl_music End Function Function update_player() For p.player=Each player If KeyDown(200) Or KeyDown(17) MoveEntity p\ent,0,0,p\speed If KeyDown(208) Or KeyDown(31) MoveEntity p\ent,0,0,-p\speed If KeyDown(203) Or KeyDown(30) MoveEntity p\ent,-p\speed/2,0,0 If KeyDown(205) Or KeyDown(32) MoveEntity p\ent,p\speed/2,0,0 player_fire() p\ammo=p\ammo-scale/3 mouselook() get_pos(p\ent) If EntityY(p\ent)>10 MoveEntity p\ent,0,-.95,0 Next End Function Function player_fire() If KeyHit(16) Stop If Not EntityCollided(beam_piv,ground) If MouseDown(1) And scale<180 scale=scale+2.0 Else If scale>0 scale=scale-4.4 End If End If If scale<0 scale=0 If scale>180 scale=180 DebugLog scale ScaleSprite beam,scale,2 PositionEntity beam_piv,0,0,-scale frame=frame+1 If frame>23 frame=0 RotateTexture beam_tex,90 EntityTexture beam,beam_tex,frame End Function Function update_enemy() For p.player=Each player For t.turret=Each turret If EntityDistance(p\ent,t\piv)<60 EntityColor t\tur,255,255,255 If EntityVisible(t\tur,p\ent) point_toward_entity(t\piv,p\ent) EntityColor t\tur,255,0,0 End If End If Next Next End Function Function load_player() p.player=New player p\ent=CreatePivot() p\cam=CreateCamera(p\ent) p\piv=CreatePivot(p\ent) p\wep=LoadMesh("media/meshes/blaster.x",p\piv) p\ammo=100 ;p\hud=LoadSprite("media/images/hud_template.png",p\cam) PositionEntity p\ent,startx,3,startz PositionEntity p\piv,1,-1.5,3 ;PositionEntity p\hud,0,0,.3 ScaleEntity p\wep,.4,.4,.4 RotateEntity p\wep,0,180,0 p\speed#=.5 beam=CreateSprite(p\wep) SpriteViewMode beam,.4 RotateEntity beam,90,90,0 beam_tex=LoadAnimTexture("media/images/beam_ani.tga",2,100,100,0,24) beam_piv=CreatePivot(p\wep) CreateSphere(8,beam_piv) EntityType beam_piv,bullet CameraClsColor p\cam,0,0,255 CameraZoom p\cam,1 CameraRange p\cam,.1,1200 EntityPickMode p\ent,1 EntityRadius p\ent,3 EntityType p\ent,playr End Function Function credits() End Function Function mouselook() For p.player=Each player ; Mouse look ; ---------- ; Mouse x and y speed mxs=MouseXSpeed() mys=MouseYSpeed() ; Mouse shake (total mouse movement) mouse_shake#=Abs(((mxs+mys)/2)/1000.0) ; Destination camera angle x and y values dest_cam_yaw#=dest_cam_yaw#-mxs dest_cam_pitch#=dest_cam_pitch#+mys ; Current camera angle x and y values cam_yaw#=cam_yaw+((dest_cam_yaw-cam_yaw)/5) cam_pitch#=cam_pitch+((dest_cam_pitch-cam_pitch)/5) RotateEntity p\ent,cam_pitch#,cam_yaw#,0 ;RotateEntity p\e,mxs,mys,0 ; Rest mouse position to centre of screen MoveMouse 400,300 Next End Function Function get_pos(entity) x=EntityX(entity) y=EntityY(entity) z=EntityZ(entity) Return x End Function Function point_toward_entity(src,dest) yaw%=DeltaYaw(src,dest) src_yaw%=EntityYaw(src) If src_yaw < yaw-1 TurnEntity src,0,1,0 If src_yaw > yaw+1 TurnEntity src,0,-1,0 If KeyHit(16) Stop End Function