tr.bb 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  1. ; Tunnel Run
  2. ; (c)2001 David Bird
  3. ; [email protected]
  4. ; www.birdie72.freeserve.co.uk
  5. ; Main Program
  6. ;
  7. Global Cheater=False
  8. Graphics3D 640,480
  9. SetBuffer BackBuffer()
  10. Include "globs.bb"
  11. Include "functions.bb"
  12. ChangeDir "Media"
  13. ;
  14. ;Set Up collision Constants here.
  15. ;
  16. Const TYPE_CAM=1
  17. Const TYPE_PLAYER=2
  18. Const TYPE_SHOT1=3
  19. Const TYPE_TUNNEL=50
  20. Const TYPE_ASTER=51
  21. Const TYPE_ASTERPOLY=52
  22. Const TYPE_CLAW=53
  23. ;
  24. ;
  25. Load_Media()
  26. Get_GFX_Modes()
  27. Load_Highscores()
  28. Set_GFXMode()
  29. Resize_Images(GraphicsWidth(),GraphicsHeight())
  30. ;
  31. Goto MainMenu
  32. End
  33. .Game_Start_Loop
  34. ;
  35. FlushMouse
  36. Create_Tunnel()
  37. lit=CreateLight()
  38. TurnEntity lit,45,0,0
  39. ;
  40. Select Gametype
  41. Case 1 ;One Player Game
  42. this.play=Add_Player(player1type,255,255,255,False,0,"Player1")
  43. Num_Players=1
  44. Case 2 ;Two Player Game
  45. this.play=Add_Player(player1type,255,255,255,True,0,"")
  46. other.play=Add_Player(player2type,255,255,0,True,1,"")
  47. Num_Players=2
  48. If Player2type>=5 Then Num_Players=2
  49. End Select
  50. Exited=False
  51. Go1_timer=0
  52. Go2_timer=0
  53. Game_Counter=0
  54. dummy=CreatePivot()
  55. Listen=CreateListener(dummy,.001,10,5)
  56. While Exited=False
  57. Game_Counter=Game_Counter+1
  58. Cls
  59. TurnEntity lit,1,1,0
  60. Update_Flash()
  61. Do_Tunnel_Scroll(Tunnel_tex,1)
  62. Do_Tunnel_Scroll(tex0,-2)
  63. Update_Shield_Texture()
  64. Do_Control()
  65. Update_Players()
  66. Update_Shots()
  67. Update_Objects()
  68. Update_Smoke()
  69. Change_Tunnel_Colors()
  70. If (Game_Counter Mod 100)=0 Then Alter_Tunnel_Colors()
  71. ;
  72. If cnt=0 Then
  73. cnt=10+(10*(3-G_Diff))
  74. Add_Object(Rnd(-300,300),Rnd(-300,300),9000,-1,Rnd(10,70),Rnd(50,150),Rand(1,3))
  75. ; Add_Object(ppop,0,10000,-1,50,4,1000)
  76. ppop=ppop+20
  77. End If
  78. ;
  79. If KeyHit(1) Then Num_Players=0:Exited=True
  80. ;
  81. cnt=cnt-1
  82. ;
  83. UpdateWorld
  84. RenderWorld
  85. lastplayer=Do_GameOver_Overlay()
  86. If lastplayer>=5 Then ppp=100
  87. If ppp>0 Then
  88. ppp=ppp-1
  89. If ppp=2 Then Exited=True
  90. End If
  91. Update_Players_Views()
  92. Flip
  93. Wend
  94. FreeEntity dummy
  95. ;Check High Scores
  96. Select gametype
  97. Case 1 ;One player Game
  98. Check_Highs(score(0),1)
  99. Case 2 ;two player Game
  100. If player1type<=4 Then
  101. Check_Highs(score(0),1)
  102. End If
  103. If player2type<=4 Then
  104. Check_Highs(score(1),2)
  105. End If
  106. End Select
  107. FreeEntity lit
  108. FreeEntity Tunnel_Mesh
  109. FreeEntity Background
  110. Free_Smoke()
  111. Free_Shots()
  112. Delete_Objects()
  113. Delete_Players()
  114. FlushMouse
  115. VWait 50
  116. Goto MainMenu
  117. ;
  118. ;
  119. Function Do_GameOver_Overlay()
  120. If Go1_Timer>0 Then
  121. Go1_Timer=Go1_timer-1
  122. If Go1_Timer>2 Then
  123. If Num_Players=1 Then pos=0 Else pos=GraphicsHeight()/4
  124. If Go2_Timer>2 Then pos=0
  125. DrawImage gover_image,0,pos
  126. Else
  127. If Num_Players=0 Then
  128. Exited=True
  129. Else
  130. lastplayer=Resize_Last_Player()
  131. End If
  132. End If
  133. End If
  134. If Go2_Timer>0 Then
  135. Go2_Timer=Go2_timer-1
  136. If Go2_Timer>2 Then
  137. If Num_Players=1 Then pos=GraphicsHeight()/2 Else pos=GraphicsHeight()/4
  138. If Go1_Timer>2 Then pos=GraphicsHeight()/2
  139. DrawImage gover_image,0,pos
  140. Else
  141. If Num_Players=0 Then
  142. Exited=True
  143. Else
  144. lastplayer=Resize_Last_Player()
  145. End If
  146. End If
  147. End If
  148. Return lastplayer
  149. End Function
  150. ;
  151. ;
  152. Function Update_Shield_Texture()
  153. shield_tex_pos=shield_tex_pos+.01
  154. If shield_tex_pos>1 Then shield_tex_pos=shield_tex_pos-1
  155. PositionTexture shield_tex,shield_tex_pos,shield_tex_pos
  156. End Function
  157. ; Create Scrolling tunnel No entity movement done
  158. ; at all. Texture scrolling screates the effect
  159. ; Makes controling bad guys a whole lot easier..
  160. ;
  161. Function Create_Tunnel()
  162. Tunnel_mesh=CreateCylinder(12)
  163. FlipMesh Tunnel_mesh
  164. ScaleMesh Tunnel_mesh,500,12000,500
  165. RotateEntity Tunnel_mesh,90,0,0
  166. EntityTexture Tunnel_mesh,Tunnel_tex,0,0
  167. EntityType tunnel_mesh,TYPE_TUNNEL
  168. PositionEntity tunnel_mesh,0,0,11400
  169. EntityColor tunnel_mesh,255,100,0
  170. t_r1=255:ta_r1=t_r1
  171. t_g1=100:ta_g1=t_g1
  172. t_b1=0:ta_b1=t_b1
  173. BackGround=CreateCylinder(12)
  174. FlipMesh BackGround
  175. ScaleMesh BackGround,510,12000,510
  176. RotateEntity BackGround,90,0,0
  177. EntityTexture BackGround,tex0,0,0
  178. PositionEntity BackGround,0,0,11400
  179. EntityColor BackGround,0,255,255
  180. t_r2=0:ta_r2=t_r2
  181. t_g2=255:ta_g2=t_g2
  182. t_b2=255:ta_b2=t_b2
  183. End Function
  184. Function Change_Tunnel_Colors()
  185. If t_r1>ta_r1 Then t_r1=t_r1-1
  186. If t_g1>ta_g1 Then t_g1=t_g1-1
  187. If t_b1>ta_b1 Then t_b1=t_b1-1
  188. If t_r2>ta_r2 Then t_r2=t_r2-1
  189. If t_g2>ta_g2 Then t_g2=t_g2-1
  190. If t_b2>ta_b2 Then t_b2=t_b2-1
  191. If t_r1<ta_r1 Then t_r1=t_r1+1
  192. If t_g1<ta_g1 Then t_g1=t_g1+1
  193. If t_b1<ta_b1 Then t_b1=t_b1+1
  194. If t_r2<ta_r2 Then t_r2=t_r2+1
  195. If t_g2<ta_g2 Then t_g2=t_g2+1
  196. If t_b2<ta_b2 Then t_b2=t_b2+1
  197. EntityColor Tunnel_mesh,t_r1,t_g1,t_b1
  198. EntityColor Background,t_r2,t_g2,t_b2
  199. End Function
  200. Function Alter_Tunnel_Colors()
  201. ta_r1=Rand(10,255):ta_g1=Rand(10,255):ta_b1=Rand(10,255)
  202. ta_r2=Rand(10,255):ta_g2=Rand(10,255):ta_b2=Rand(10,255)
  203. End Function
  204. Function Resize_Images(Width,Height)
  205. ResizeImage TitleScreen1,Width,Height
  206. ResizeImage gover_image,Width,Height/2
  207. End Function
  208. ;
  209. ;
  210. ;
  211. Function Load_media()
  212. Tunnel_tex=LoadTexture("tex0.bmp",6):ScaleTexture Tunnel_tex,1,2
  213. tex0=LoadTexture("tex0.bmp"):ScaleTexture tex0,.5,.5
  214. Shield_tex=LoadTexture("tex1.bmp",3)
  215. Rock_Tex=LoadTexture("stone04.bmp")
  216. ;
  217. ; Global Meshes
  218. ;
  219. Aster_mesh=LoadMesh("asteroid.3ds"):EntityTexture Aster_Mesh,Rock_tex
  220. ScaleMesh Aster_mesh,.005,.005,.005
  221. HideEntity Aster_Mesh
  222. ;
  223. player_mesh=LoadMesh("hfighter.3ds")
  224. ScaleEntity player_mesh,8,9,11
  225. HideEntity player_mesh
  226. ;
  227. shield_mesh=CreateSphere()
  228. ScaleEntity shield_mesh,55,35,60
  229. EntityTexture shield_mesh,shield_tex
  230. HideEntity shield_mesh
  231. ;
  232. missile1_mesh=LoadMesh("missile1.3ds")
  233. RotateMesh missile1_mesh,Pi,0,0
  234. ScaleMesh missile1_mesh,2,2,2
  235. temptex=LoadTexture("tex2.bmp")
  236. EntityTexture missile1_mesh,temptex
  237. HideEntity missile1_mesh
  238. FreeTexture temptex
  239. ;
  240. Bad01_mesh=CreateSphere()
  241. HideEntity bad01_mesh
  242. claw_anim_mesh=LoadAnimMesh("claw.3ds")
  243. HideEntity claw_anim_mesh
  244. ;
  245. ;
  246. ; Sprites
  247. ;
  248. shot1_spr=LoadSprite("shot1.bmp")
  249. HideEntity shot1_spr
  250. ScaleSprite shot1_spr,32,16
  251. ;
  252. For a=1 To 4
  253. b$="smoke"+a+".bmp"
  254. smoke_spr(a)=LoadSprite(b$)
  255. HideEntity smoke_spr(a)
  256. Next
  257. target_spr=LoadSprite("target.bmp"):HideEntity target_spr
  258. ;
  259. ; 2DImages
  260. Titlescreen1=LoadImage("title.bmp")
  261. Mousepointer=LoadImage("mouse.bmp"):MaskImage MousePointer,255,255,0
  262. Lives_Image=LoadImage("lives.bmp")
  263. Gover_Image=LoadImage("go.bmp")
  264. ;
  265. ;
  266. ;Sounds
  267. Shoot1_wave=LoadSound("shoot.wav")
  268. Explode_Wave=LoadSound("boom.wav")
  269. End Function
  270. Function Free_media()
  271. If Tunnel_tex<>0 Then FreeTexture tunnel_tex:tunnel_tex=0
  272. If tex0<>0 Then FreeTexture tex0:tex0=0
  273. If Shield_tex<>0 Then FreeTexture Shield_Tex:Shield_Tex=0
  274. If Rock_Tex<>0 Then FreeTexture Rock_Tex:Rock_Tex=0
  275. If temptex<>0 Then FreeTexture temptex:temptex=0
  276. ;
  277. ; Global Meshes
  278. ;
  279. If Aster_mesh<>0 Then FreeEntity Aster_mesh:Aster_Mesh=0
  280. If player_mesh<>0 Then FreeEntity player_mesh:player_mesh=0
  281. If shield_mesh<>0 Then FreeEntity shield_mesh:shield_mesh=0
  282. If missile1_mesh<>0 Then FreeEntity missile1_mesh:missile1_mesh=0
  283. ;
  284. If Bad01_mesh<>0 Then FreeEntity bad01_mesh:Bad01_mesh=0
  285. If Claw_Anim_Mesh<>0 Then FreeEntity Claw_Anim_Mesh:Claw_Anim_Mesh=0
  286. ;
  287. ;
  288. ; Sprites
  289. ;
  290. If shot1_spr<>0 Then FreeEntity shot1_spr:shot1_spr=0
  291. ;
  292. For a=1 To 4
  293. If smoke_spr(a)<>0 Then FreeEntity smoke_spr(a):smoke_spr(a)=0
  294. Next
  295. If target_spr<>0 Then FreeEntity target_spr:Target_Spr=0
  296. ;
  297. ; 2DImages
  298. If Titlescreen1<>0 Then FreeImage Titlescreen1:Titlescreen1=0
  299. If Mousepointe<>0 Then FreeImage MousePointer:MousePointer=0
  300. If Lives_Image<>0 Then FreeImage Lives_image:Lives_image=0
  301. If Gover_Image<>0 Then FreeImage Gover_Image:Gover_Image=0
  302. ;
  303. ;Sounds
  304. If Shoot1_wave<>0 Then FreeSound Shoot1_wave:Shoot1_wave=0
  305. If Explode_Wave<>0 Then FreeSound Explode_Wave:Explode_Wave=0
  306. End Function
  307. ;
  308. ; Trick scrolling
  309. ; Move the texture
  310. Function Do_Tunnel_Scroll(texture,div#)
  311. Tunnel_Texture_Coord=Tunnel_Texture_Coord+Scroll_speed
  312. If Tunnel_Texture_Coord>1 Then Tunnel_Texture_Coord=Tunnel_Texture_Coord-1
  313. PositionTexture texture,Tunnel_Texture_Coord/div,Tunnel_Texture_Coord
  314. End Function
  315. ;
  316. ; Control an entity
  317. ;
  318. ; Player functions
  319. ; typ = 1 Mouse controled player
  320. ; 2 ana Joy Controlled player
  321. ; 3 dig Joy controlled player
  322. ; 4 keyboard controlled player
  323. ; 5 CPU Controlled player
  324. ; 6 internet player ** TO DO **
  325. Function Do_Control()
  326. For a.play=Each play
  327. If a\dead=False Then
  328. Select a\con
  329. Case 1 ;Mouse Controlled
  330. Do_MouseMove(a)
  331. Case 2 ;analog controlled
  332. Do_JoyMove(a)
  333. Case 3 ;directional joy controlled
  334. Do_JoyDirMove(a)
  335. Case 4 ;keyboard controlled
  336. Do_KeyMove(a)
  337. Case 5 ;CPU Controlled
  338. CPU_Move(a)
  339. Case 6 ;Internet controlled
  340. End Select
  341. End If
  342. Next
  343. End Function
  344. Function Do_MouseMove(a.play)
  345. dx#=MouseXSpeed()/2
  346. dy#=MouseYSpeed()/2
  347. If dx>0 Then a\roll=a\roll-4
  348. If dx<0 Then a\roll=a\roll+4
  349. If dy>0 Then a\pich=a\pich-4
  350. If dy<0 Then a\pich=a\pich+4
  351. If a\pich<>0 Then a\pich=a\pich*.85
  352. If a\roll<>0 Then a\roll=a\roll*.85
  353. RotateEntity a\piv,a\pich,0,a\roll
  354. TranslateEntity a\piv,dx,dy,0
  355. MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
  356. If MouseDown(1) Then Add_Shot(a\piv,1,10,a)
  357. End Function
  358. Function Do_JoyMove(a.play)
  359. dx#=JoyX()
  360. dy#=JoyY()
  361. If dx>-Dead_BandX And dx<Dead_BandX Then dx=0
  362. If dy>-Dead_BandY And dy<Dead_BandY Then dy=0
  363. dx=dx*5
  364. dy=dy*5
  365. If dx>0 Then a\roll=a\roll-4
  366. If dx<0 Then a\roll=a\roll+4
  367. If dy>0 Then a\pich=a\pich-4
  368. If dy<0 Then a\pich=a\pich+4
  369. If a\pich<>0 Then a\pich=a\pich*.85
  370. If a\roll<>0 Then a\roll=a\roll*.85
  371. RotateEntity a\piv,a\pich,0,a\roll
  372. TranslateEntity a\piv,dx,dy,0
  373. If JoyDown(1) Then Add_Shot(a\piv,1,10,a)
  374. End Function
  375. Function Do_JoyDirMove(a.play)
  376. dx#=JoyXDir()*5
  377. dy#=JoyYDir()*5
  378. If dx>0 Then a\roll=a\roll-4
  379. If dx<0 Then a\roll=a\roll+4
  380. If dy>0 Then a\pich=a\pich-4
  381. If dy<0 Then a\pich=a\pich+4
  382. If a\pich<>0 Then a\pich=a\pich*.85
  383. If a\roll<>0 Then a\roll=a\roll*.85
  384. RotateEntity a\piv,a\pich,0,a\roll
  385. TranslateEntity a\piv,dx,dy,0
  386. If JoyDown(1) Then Add_Shot(a\piv,1,10,a)
  387. End Function
  388. Function Do_KeyMove(a.play)
  389. If KeyDown(Keys(1)) Then dx#=-5
  390. If KeyDown(Keys(2)) Then dx#=5
  391. If KeyDown(Keys(3)) Then dy#=-5
  392. If KeyDown(Keys(4)) Then dy#=5
  393. If dx>0 Then a\roll=a\roll-4
  394. If dx<0 Then a\roll=a\roll+4
  395. If dy>0 Then a\pich=a\pich-4
  396. If dy<0 Then a\pich=a\pich+4
  397. If a\pich<>0 Then a\pich=a\pich*.85
  398. If a\roll<>0 Then a\roll=a\roll*.85
  399. RotateEntity a\piv,a\pich,0,a\roll
  400. TranslateEntity a\piv,dx,dy,0
  401. If KeyDown(keys(5)) Then Add_Shot(a\piv,1,10,a)
  402. End Function
  403. Function CPU_Move(a.play)
  404. b.Obj=Find_Closest_Target()
  405. If b<>Null Then
  406. dx#=(EntityX(b\piv)-EntityX(a\piv))/60
  407. dy#=(EntityY(b\piv)-EntityY(a\piv))/60
  408. If dx>0 Then a\roll=a\roll-2
  409. If dx<0 Then a\roll=a\roll+2
  410. If dy>0 Then a\pich=a\pich-2
  411. If dy<0 Then a\pich=a\pich+2
  412. If a\pich<>0 Then a\pich=a\pich*.85
  413. If a\roll<>0 Then a\roll=a\roll*.85
  414. RotateEntity a\piv,a\pich,0,a\roll
  415. TranslateEntity a\piv,dx,dy,0
  416. ent=LinePick(EntityX(a\piv),EntityY(a\piv),EntityZ(a\piv)+50,0,0,5000)
  417. If dx>-2.5 And dx<2.5 Then
  418. If dy>-2.5 And dy<2.5 Then
  419. Add_Shot(a\piv,1,10,a)
  420. End If
  421. End If
  422. End If
  423. End Function
  424. Function Find_Obj_From_Ent.Obj(ent)
  425. For a.obj=Each obj
  426. If a\piv=ent Or a\ent=ent Then Return a
  427. Next
  428. Return Null
  429. End Function
  430. Function Find_Closest_Target.Obj()
  431. z#=1000000
  432. minz#=100
  433. For a.Obj=Each Obj
  434. If EntityZ(a\piv,True)>0 Then
  435. If EntityZ(a\piv,True)<z And EntityZ(a\piv,True)>minz Then target.Obj=a:z=EntityZ(a\piv,True)
  436. End If
  437. Next
  438. Return target
  439. End Function
  440. ;
  441. Type play
  442. Field name$
  443. Field rate
  444. Field ox#
  445. Field cam
  446. Field con
  447. Field piv
  448. Field ent
  449. Field shield_ent
  450. Field glow#
  451. Field dead
  452. Field pich#
  453. Field roll#
  454. Field shield#
  455. Field score
  456. Field waiting
  457. Field id
  458. ;
  459. Field tlx
  460. Field tly
  461. Field brx
  462. Field bry
  463. Field lives
  464. End Type
  465. ;
  466. ;
  467. ;
  468. Type shot
  469. Field typ
  470. Field ent
  471. Field life#
  472. Field dx#
  473. Field dy#
  474. Field dz#
  475. Field speed#
  476. Field ang#
  477. Field firer.play
  478. Field target.Obj
  479. End Type
  480. ;
  481. ; Object
  482. ;
  483. ; 1-3 are asteroids
  484. Type Obj
  485. Field typ
  486. Field piv
  487. Field ent
  488. Field val
  489. Field col
  490. Field cd
  491. Field speed#
  492. Field dx#
  493. Field dy#
  494. Field ds#
  495. Field fx
  496. Field fy
  497. Field dir
  498. Field st
  499. Field cnt
  500. End Type
  501. ;
  502. ; Smoke Effect
  503. ;
  504. Type smoke
  505. Field alpha#
  506. Field reduct#
  507. Field ent
  508. Field size#
  509. Field rot#
  510. Field disp#
  511. End Type
  512. .MainMenu
  513. SetBuffer BackBuffer()
  514. Cls
  515. FlushMouse:FlushKeys
  516. Game_Start=False
  517. Exit_Game=False
  518. Options=False
  519. While Not Game_Start=True
  520. cntr=cntr+1
  521. If MouseXSpeed()+MouseYSpeed()<>0 Then cntr=0
  522. Cls
  523. DrawImage TitleScreen1,0,0
  524. sel=0
  525. If cntr<500 Then
  526. Draw_Menu(True,0,0)
  527. sel=Draw_Menu(False,-2,-2)
  528. If MouseHit(1) Then
  529. Select sel
  530. Case 1
  531. If gametype=1 Then gametype=2 Else gametype=1
  532. Case 2
  533. player1type=player1type+1
  534. If player1type>6 Then player1type=1
  535. If player2type=player1type Then player1type=player1type+1
  536. Case 3
  537. player2type=player2type+1
  538. If player2type>6 Then player2type=1
  539. If player2type=player1type Then player2type=player2type+1
  540. Case 4
  541. Game_Start=True
  542. Options=True
  543. Case 5
  544. Case 6
  545. If player1type<>6 And player2type<>6 Then
  546. Game_Start=True
  547. End If
  548. Case 7
  549. Exit_Game=True
  550. Game_Start=True
  551. End Select
  552. End If
  553. Else
  554. If cntr>1000 Then cntr=0
  555. Draw_Highs(True,0,0)
  556. Draw_Highs(False,-2,-2)
  557. End If
  558. DrawImage MousePointer,MouseX(),MouseY()
  559. Flip
  560. Wend
  561. cntr=0
  562. If Options=True Then Goto Options
  563. If Exit_Game=True Then Goto Exit_Game_Sub
  564. If Game_Start=True Then Goto Game_Start_Loop
  565. RuntimeError "Game Ended Abnormally"
  566. EndGraphics
  567. End
  568. ;
  569. ; Exit Game / Save Highs etc
  570. ; Do Credits
  571. .Exit_Game_Sub
  572. Save_Highscores()
  573. ChangeDir ".."
  574. EndGraphics
  575. End
  576. ;
  577. ;
  578. ;Save Highscores and options
  579. Function Load_Highscores()
  580. p=0
  581. file=ReadFile("../Highs/Highs.Hsr")
  582. For a=1 To 10
  583. Hn$(a)=ReadLine$(file)
  584. Hs(a)=ReadInt(file)
  585. Next
  586. G_Brightness=ReadInt(file)
  587. G_StartLives=ReadInt(file)
  588. G_Diff=ReadInt(file)
  589. G_CurrentGFX=ReadInt(file)
  590. End Function
  591. Function Save_Highscores()
  592. p=0
  593. file=WriteFile("../Highs/Highs.Hsr")
  594. For a=1 To 10
  595. WriteLine file,Hn$(a)
  596. WriteInt file,Hs(a)
  597. Next
  598. WriteInt file,G_Brightness
  599. WriteInt file,G_StartLives
  600. WriteInt file,G_Diff
  601. WriteInt file,G_CurrentGFX
  602. End Function
  603. Function Draw_Menu(col,ox,oy)
  604. sel=0
  605. For a=1 To 7
  606. b$=""
  607. If col=True Then Color 0,0,0 Else Color 255,255,255
  608. p=0
  609. Select a
  610. Case 1
  611. b$=Menu$(a)+GM_TYPE(gametype)
  612. Case 2
  613. b$=Menu$(a)+CN_TYPE(player1type)
  614. Case 3
  615. If gametype=2 Then
  616. b$=Menu$(a)+CN_TYPE(player2type)
  617. End If
  618. Default
  619. b$=Menu(a)
  620. End Select
  621. c#=(Float(a)*32)/2
  622. w=Len(b$)*8
  623. y=GraphicsHeight()/2
  624. y=((y-c)+a*32)-oy
  625. x=(GraphicsWidth()/2)-ox-(w/2)
  626. h=16
  627. If RectsOverlap(x,y,w,h,MouseX(),MouseY(),1,1) Then sel=a:p=1
  628. If p<>0 And col=False Then Color Rnd(255),Rnd(255),Rnd(255)
  629. Text x,y,b$
  630. Next
  631. Return sel
  632. End Function
  633. ;
  634. ;Draw High's
  635. Function Draw_Highs(col,ox,oy)
  636. For a=1 To 10
  637. If col=True Then Color 0,0,0 Else Color 255,255,255
  638. b$=a+" "+hn$(a)+" "+hs(a)
  639. c#=(Float(a)*32)/2
  640. w=Len(b$)*8
  641. y=GraphicsHeight()/2
  642. y=((y-c)+a*32)-oy
  643. x=(GraphicsWidth()/2)-ox-(w/2)
  644. h=16
  645. Text x,y,b$
  646. Next
  647. End Function
  648. Function Check_Highs(score,id)
  649. If score>hs(10) Then ; Got a high Score
  650. ps=0
  651. For a=10 To 1 Step -1
  652. If score>hs(a) Then
  653. ps=a
  654. hs(a+1)=hs(a)
  655. hn(a+1)=hn(a)
  656. End If
  657. Next
  658. If ps<>0 Then
  659. hs(ps)=score
  660. SetBuffer FrontBuffer()
  661. Cls
  662. DrawImage TitleScreen1,0,0
  663. Color 0,0,0
  664. Text 0,GraphicsHeight()/2,"Well Done Player "+id+". Your On the High Score Table",0,1
  665. Color 255,255,255
  666. Text 2,2+GraphicsHeight()/2,"Well Done Player "+id+". Your On the High Score Table",0,1
  667. Locate GraphicsWidth/2,GraphicsHeight()/2+16
  668. hn(ps)=Input$("Enter Your Name ?")
  669. SetBuffer BackBuffer()
  670. cntr=1000
  671. End If
  672. End If
  673. End Function
  674. .dats
  675. ;Game Type
  676. Data "One Player Game"
  677. Data "Two Player Game"
  678. ;Control Type
  679. Data "Mouse Control"
  680. Data "Analog Joystick"
  681. Data "Digital Joystick"
  682. Data "Keyboard (Not Recommended)"
  683. Data "CPU"
  684. Data "Network Game(Not Availible)"
  685. ;Menus
  686. Data "Game Type:"
  687. Data "Player One Control:"
  688. Data "Player Two Control:"
  689. Data "Options"
  690. Data ""
  691. Data "START GAME"
  692. Data "QUIT GAME"
  693. .highs
  694. Data "David Bird",100000
  695. Data "Made With",90000
  696. Data "The Great",80000
  697. Data "Blitz Basic3D",70000
  698. Data "(c)2001 David Bird",60000
  699. Data "Donna Bird",50000
  700. Data "Jessica Bird",40000
  701. Data "Rebecca Bird",30000
  702. Data "Daniel Bird",20000
  703. Data "David Bird",10000
  704. Data "",0
  705. .Options
  706. Create_Tunnel()
  707. OptTunnel=CopyEntity(Tunnel_Mesh):FreeEntity Tunnel_Mesh
  708. OptBackground=CopyEntity(Background):FreeEntity Background
  709. Optlight=CreateLight()
  710. TurnEntity OptLight,45,0,0
  711. OptCamera=CreateCamera()
  712. CameraRange Optcamera,1,25000
  713. While Not KeyDown(1)
  714. AmbientLight G_Brightness,G_Brightness,G_Brightness
  715. UpdateWorld
  716. RenderWorld
  717. G_Brightness=Draw_slider("Brightness",50,50,300,16,G_Brightness,255,5,50)
  718. G_StartLives=Draw_slider("Number of Lives",50,75,300,16,G_StartLives,5,1,150)
  719. If G_StartLives<1 Then G_StartLives=1
  720. G_Diff=Draw_slider("Difficulty",50,100,300,16,G_Diff,3,1,150)
  721. G_CurrentGFX=Draw_GFX_Selector(G_CurrentGFX,50,130)
  722. DrawImage MousePointer,MouseX(),MouseY()
  723. Text GraphicsWidth()/2,GraphicsHeight()-16,"Press Escape to Return to Main Menu",1,0
  724. Flip
  725. Wend
  726. If OptLight<>0 Then FreeEntity OptLight:OptLight=0
  727. If OptTunnel<>0 Then FreeEntity OptTunnel:OptTunnel=0
  728. If OptBackground<>0 Then FreeEntity OptBackground:OptBackground=0
  729. If OptCamera<>0 Then FreeEntity OptCamera:OptCamera=0
  730. Goto MainMenu
  731. Function Draw_slider(txt$,x,y,Ln#,hg,pos#,scale#,Stp,dely)
  732. sel=0
  733. Rect x,y,ln,hg,0
  734. Rect x+ln,y,16,hg,0:Text x+ln+8,y+(hg/2)-1,"-",1,1
  735. If RectsOverlap(x+ln,y,16,16,MouseX(),MouseY(),1,1) Then sel=1
  736. Rect x+ln+16,y,16,hg,0:Text x+ln+24,y+(hg/2)-1,"+",1,1
  737. If RectsOverlap(x+ln+16,y+(hg/2)-1,16,16,MouseX(),MouseY(),1,1) Then sel=2
  738. ps=(ln/scale)*pos
  739. Rect ps+x,y,2,hg,1
  740. Text x+ln+38,y,txt+" "+Int(Pos)
  741. newval=pos
  742. If MouseDown(1) And sel<>0 Then
  743. Delay dely
  744. If sel=1 And newval>0 Then newval=newval-stp
  745. If sel=2 And newval<scale Then newval=newval+stp
  746. End If
  747. If newval<0 Then newval=0
  748. If newval>scale Then newval=scale
  749. Return newval
  750. End Function
  751. Function Draw_GFX_Selector(current,x,y)
  752. Rect x-4,y-4,150,24,0
  753. sel=0
  754. Rect x+150,y-4,16,24,0:Text x+158,y+6,"-",1,1
  755. If RectsOverlap(x+150,y-4,16,24,MouseX(),MouseY(),1,1) Then sel=1
  756. Rect x+166,y-4,16,24,0:Text x+172,y+6,"+",1,1
  757. If RectsOverlap(x+166,y-4,16,24,MouseX(),MouseY(),1,1) Then sel=2
  758. Rect x+182,y-4,24,24,0:Text x+194,y+6,"GO",1,1
  759. If RectsOverlap(x+182,y-4,24,24,MouseX(),MouseY(),1,1) Then sel=3
  760. p.GfxMode=First GfxMode
  761. For r=1 To current
  762. p=After p
  763. Next
  764. Text x,y,p\t$
  765. If MouseDown(1) And sel<>0 Then
  766. Delay 100
  767. If sel=1 And current>1 Then current=current-1
  768. If sel=2 And current<Max_GFXModes Then current=current+1
  769. If sel=3 Then ;Reset GFXMODE
  770. If OptLight<>0 Then FreeEntity OptLight:OptLight=0
  771. If OptTunnel<>0 Then FreeEntity OptTunnel:OptTunnel=0
  772. If OptBackground<>0 Then FreeEntity OptBackground:OptBackground=0
  773. If OptCamera<>0 Then FreeEntity OptCamera:OptCamera=0
  774. Set_GFXMode()
  775. Create_Tunnel()
  776. OptTunnel=CopyEntity(Tunnel_Mesh):FreeEntity Tunnel_Mesh
  777. OptBackground=CopyEntity(Background):FreeEntity Background
  778. Optlight=CreateLight()
  779. TurnEntity OptLight,45,0,0
  780. OptCamera=CreateCamera()
  781. CameraRange Optcamera,1,25000
  782. End If
  783. End If
  784. Return current
  785. End Function
  786. Type GfxMode
  787. Field width,height,depth
  788. Field t$
  789. End Type
  790. Function Get_GFX_Modes()
  791. cnt=0
  792. For k=1 To CountGfxModes()
  793. If GfxMode3D(k)
  794. t.GfxMode=New GfxMode
  795. t\width=GfxModeWidth(k)
  796. t\height=GfxModeHeight(k)
  797. t\depth=GfxModeDepth(k)
  798. t\t$=t\width+","+t\height+","+t\Depth
  799. cnt=cnt+1
  800. EndIf
  801. Next
  802. Max_GFXModes=cnt-1
  803. End Function
  804. Function Set_GFXMode()
  805. m.GfxMode=First GfxMode
  806. For r=1 To G_CurrentGFX
  807. m=After m
  808. Next
  809. Free_Media()
  810. ClearCollisions
  811. Graphics3D m\width,m\height,m\depth,1
  812. SetBuffer BackBuffer()
  813. Load_Media()
  814. Text GraphicsWidth()/2,GraphicsHeight()/2,"Please Wait Initialising Graphics",1,1
  815. Flip
  816. Resize_Images(GraphicsWidth(),GraphicsHeight())
  817. ;Do Collision Table Here
  818. Collisions TYPE_CAM,TYPE_TUNNEL,2,2
  819. Collisions TYPE_PLAYER,TYPE_TUNNEL,2,2
  820. Collisions TYPE_ASTER,TYPE_PLAYER,1,2
  821. Collisions TYPE_PLAYER,TYPE_ASTER,1,2
  822. Collisions TYPE_SHOT1,TYPE_ASTER,1,1
  823. Collisions TYPE_PLAYER,TYPE_PLAYER,1,1
  824. Collisions TYPE_PLAYER,TYPE_CLAW,2,2
  825. End Function