wing_ring.bb 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847
  1. ; ------------------------------------
  2. ; Name: Wing Ring
  3. ; Version: V1.0
  4. ; Author: Simon Harrison
  5. ; Email: [email protected]
  6. ; Website: http://www.si-design.co.uk
  7. ; Date: 18/09/01
  8. ; ------------------------------------
  9. ; Player 1 - Keyboard. A = Forward. S = Shoot. Cursor keys = Move.
  10. ; Player 2 - Joypad.
  11. AppTitle "Wing Ring V1.0"
  12. Global width=640,height=480,depth=16,mode=1
  13. Graphics3D width,height,depth,mode
  14. SetBuffer BackBuffer()
  15. SeedRnd MilliSecs()
  16. ; --------------
  17. ; Menu variables
  18. ; --------------
  19. ; Menu background
  20. Global logo,logo_width,logo_height,tile_y ; Logo-related variables
  21. Global cr#,cg#,cb# ; Current red, green, blue values
  22. Global dr#,dg#,db# ; Destination red, green, blue values
  23. Global sr#,sg#,sb# ; Step red, green, blue values
  24. Global col,ct,fade=100 ; Current colour, time, fade
  25. ; Menu text spacing
  26. Global y_space#=height/18,option=4,screen
  27. Global x_space=width/71,x_nos=((width/4)-((9*3)/2)),x_names=((width/2)-((9*5)/2)),x_scores=((width/1.33)-((9*5)/2))
  28. ; Graphics modes
  29. Global count_gfx_modes=CountGfxModes(),gfx_mode_option,mode_option=1
  30. ; Arrays
  31. Dim greyscale(0,0)
  32. Dim gfx_modes(0,2)
  33. Dim names$(11),scores(11) : scores(11)=0
  34. ; High score rank
  35. Global rank
  36. ; ----------------------
  37. ; General game variables
  38. ; ----------------------
  39. ; Game-timing stuff
  40. Const fps=60
  41. Global elapsed,time,tween#,period=1000/fps
  42. ; Collision types
  43. Const type_none=0,type_plane1=1,type_plane1_bullet=2,type_plane2=3,type_plane2_bullet=4,type_ufo=5,type_ufo_bullet=6,type_statue=7
  44. ; No of players
  45. Global no_players
  46. ; Score values
  47. Global pot1,bank1 ; Player 1
  48. Global pot2,bank2 ; Player 2
  49. ; Game over values
  50. Global game_over1=False,game_over1_delay ; Player 1
  51. Global game_over2,game_over2_delay ; Player 2
  52. ; -----------------------------
  53. ; Lighting and camera variables
  54. ; -----------------------------
  55. ; Light and camera entities
  56. Global light
  57. Global main_cam1,top_cam1 ; Player 1
  58. Global main_cam2,top_cam2 ; Player 2
  59. ; Camera 1 position values
  60. Global cam1_x#,cam1_y#=1000,cam1_z#,cam1_ay#=180 ; Current values
  61. Global cam1_dx#,cam1_dy#=1000,cam1_dz#,cam1_day#=180 ; Destination values
  62. ; Camera 2 position values
  63. Global cam2_x#,cam2_y#=1000,cam2_z#,cam2_ay#=180 ; Current values
  64. Global cam2_dx#,cam2_dy#=1000,cam2_dz#,cam2_day#=180 ; Destination values
  65. ; -----------------
  66. ; Scenery variables
  67. ; -----------------
  68. ; Scenery entities
  69. Global sphinx,liberty,ground,ring,sky,sun,moon
  70. ; Senery textures
  71. Global sand_tex,lights_tex,lights_multi_tex,sky_tex,night_sky_tex
  72. ; Pointers to scenery entities (sort of)
  73. Global statue,solar,solar_y,solar_z,solar_scale,solar_scale_shake
  74. ; Scenery value
  75. Global scenery
  76. ; Ring values
  77. Global red_ring_x#=0,red_ring_z#=0,red_ring_radius#=625
  78. Global orange_ring_x#=0,orange_ring_z#=2773.4375,orange_ring_radius#=1406.25
  79. Global yellow_ring_x#=2578.125,yellow_ring_z#=898.4375,yellow_ring_radius#=1250
  80. Global green_ring_x#=-2578.125,green_ring_z#=898.4375,green_ring_radius#=1093.75
  81. Global blue_ring_x#=1601.5625,blue_ring_z#=-2187.5,blue_ring_radius#=937.5
  82. Global pink_ring_x#=-1601.5625,pink_ring_z#=-2187.5,pink_ring_radius#=781.25
  83. ; ---------------
  84. ; Plane variables
  85. ; ---------------
  86. ; Plane entities
  87. Global plane1,shield1 ; Player 1
  88. Global plane2,shield2 ; Player 2
  89. ; Player 1 position values
  90. Global plane1_x#,plane1_y#=1000,plane1_z#,plane1_ay#=180 ; Current values
  91. Global plane1_dx#,plane1_dy#=1000,plane1_dz#,plane1_day#=180 ; Destination values
  92. ; Player 2 position values
  93. Global plane2_x#,plane2_y#=1000,plane2_z#,plane2_ay#=180 ; Current values
  94. Global plane2_dx#,plane2_dy#=1000,plane2_dz#,plane2_day#=180 ; Destination values
  95. ; Plane + camera curve values
  96. Global curve_plane#=10,curve_cam#=15
  97. ; ---------------
  98. ; Enemy variables
  99. ; ---------------
  100. ; Enemy entities
  101. Global mother_pivot,mother
  102. Global orange_ufo,blue_ufo,green_ufo,pink_ufo,yellow_ufo
  103. Global orange_shadow,blue_shadow,green_shadow,pink_shadow,yellow_shadow
  104. ; New ufos
  105. Global mother_timer=MilliSecs(),ufo_count,new_ufo,no_ufos,max_ufos=15
  106. ; Ufo trail
  107. Global trail_timer=MilliSecs(),trail_timer_reset=False
  108. ; -------------------
  109. ; Explosion variables
  110. ; -------------------
  111. ; Explosion entities
  112. Global bullet,orange_spark,blue_spark,green_spark,pink_spark,yellow_spark,debris
  113. ; Points entities
  114. Global points_200,points_200x2,points_200x4,points_200x6,points_200x8,points_200x10
  115. Global points_400,points_400x2,points_400x4,points_400x6,points_400x8,points_400x10
  116. Global points_600,points_600x2,points_600x4,points_600x6,points_600x8,points_600x10
  117. Global points_800,points_800x2,points_800x4,points_800x6,points_800x8,points_800x10
  118. Global points_1000,points_1000x2,points_1000x4,points_1000x6,points_1000x8,points_1000x10
  119. Global points_bust
  120. ; Intensity of explosions
  121. Global plane_intensity=100,ufo_intensity=50
  122. ; ----------------------
  123. ; Bonus camels variables
  124. ; ----------------------
  125. ; Camel entities
  126. Global orange_camel,yellow_camel,green_camel,blue_camel,pink_camel
  127. ; Player 1 bonus values
  128. Global plane1_bonus ; Variable containing value of bonus collected
  129. Global orange_bonus1_time,orange_bonus1_status
  130. Global yellow_bonus1_time,yellow_bonus1_status,yellow_bonus1_pause
  131. Global green_bonus1_time,green_bonus1_status
  132. Global blue_bonus1_time,blue_bonus1_status
  133. Global pink_bonus1_time,pink_bonus1_status
  134. ; Player 2 bonus values
  135. Global plane2_bonus ; Variable containing value of bonus collected
  136. Global orange_bonus2_time,orange_bonus2_status
  137. Global yellow_bonus2_time,yellow_bonus2_status,yellow_bonus2_pause
  138. Global green_bonus2_time,green_bonus2_status
  139. Global blue_bonus2_time,blue_bonus2_status
  140. Global pink_bonus2_time,pink_bonus2_status
  141. ; -------------------------------
  142. ; Fonts + music + sound variables
  143. ; -------------------------------
  144. ; Fonts
  145. Global small_font,large_font
  146. ; Music
  147. Global music
  148. ; Sounds
  149. Global explode
  150. ; -----
  151. ; Types
  152. ; -----
  153. Type plane1_bullet
  154. Field entity,alpha#
  155. End Type
  156. Type plane2_bullet
  157. Field entity,alpha#
  158. End Type
  159. Type ufo
  160. Field entity,shadow,colour,target,x#,y#,z#,dx#,dy#,dz#,count
  161. End Type
  162. Type trail
  163. Field entity,alpha#,count
  164. End Type
  165. Type ufo_bullet
  166. Field entity,alpha#
  167. End Type
  168. Type bullet_trail
  169. Field entity,alpha#
  170. End Type
  171. Type shadow
  172. Field entity,scale#,alpha#
  173. End Type
  174. Type spark
  175. Field entity,alpha#,y_speed#
  176. End Type
  177. Type points
  178. Field entity,scale#,alpha#
  179. End Type
  180. Type camel
  181. Field entity,colour,alpha#
  182. End Type
  183. ; -------------
  184. ; Pre-main loop
  185. ; -------------
  186. Include "menus.bb"
  187. Include "scenery.bb"
  188. Include "player2.bb"
  189. InitMenus()
  190. LoadMedia()
  191. CreateEntities()
  192. InitCollisions()
  193. ; ---------
  194. ; Main loop
  195. ; ---------
  196. While Not KeyHit(1)
  197. Background()
  198. ; Screen functions
  199. Select screen
  200. Case 4 : no_players=1 : Game()
  201. Case 5 : no_players=2 : Game()
  202. Case 6 : HighScores()
  203. Case 7 : Options()
  204. Default : Credits()
  205. End Select
  206. Flip
  207. Wend
  208. End ; End of program.
  209. ; -------------
  210. ; Game Function
  211. ; -------------
  212. Function Game()
  213. ; Use random scenery
  214. scenery=1-scenery
  215. If scenery=1 Then Egypt()
  216. If scenery=0 Then USA()
  217. StartGame()
  218. While KeyHit(1)<>True And (game_over1_delay<=120 Or game_over2_delay<=120)
  219. Repeat
  220. elapsed=MilliSecs()-time
  221. Until elapsed
  222. tween#=Float(elapsed)/Float(period)
  223. While tween>=1
  224. tween=tween-1
  225. time=time+period
  226. If tween<1 Then CaptureWorld
  227. UpdateGame()
  228. UpdateWorld
  229. Wend
  230. RenderWorld ;tween
  231. Render2D()
  232. Flip
  233. Wend
  234. EndGame()
  235. If screen<>6 Then screen=0
  236. End Function
  237. ; --------------------
  238. ; Update game function
  239. ; --------------------
  240. Function UpdateGame()
  241. If game_over1=False
  242. GameInput1()
  243. UpdatePlane1()
  244. UpdateCamels1()
  245. CheckCollisions1()
  246. Else
  247. game_over1_delay=game_over1_delay+1
  248. EndIf
  249. ; 2 player only
  250. If no_players=2
  251. If game_over2=False
  252. GameInput2()
  253. UpdatePlane2()
  254. UpdateCamels2()
  255. CheckCollisions2()
  256. Else
  257. game_over2_delay=game_over2_delay+1
  258. EndIf
  259. EndIf
  260. UpdateMother()
  261. UpdateUFO()
  262. UpdateExplosions()
  263. UpdateExtras()
  264. End Function
  265. ; -------------------
  266. ; Start game function
  267. ; -------------------
  268. Function StartGame()
  269. no_ufos=0
  270. ufo_count=0
  271. game_over2_delay=1000 ; Make sure it's game over for player 2 if we are having a one-player game!
  272. game_over1=False
  273. game_over1_delay=0
  274. plane1_x#=0
  275. plane1_z#=0
  276. plane1_ay#=180
  277. plane1_dx#=0
  278. plane1_dz#=0
  279. plane1_day#=180
  280. cam1_x#=0
  281. cam1_z#=0
  282. cam1_ay#=180
  283. cam1_dx#=0
  284. cam1_dz#=0
  285. cam1_day#=180
  286. pot1=0
  287. bank1=0
  288. orange_bonus1_time=0
  289. yellow_bonus1_time=0
  290. green_bonus1_time=0
  291. blue_bonus1_time=0
  292. pink_bonus1_time=0
  293. CameraViewport main_cam1,0,0,width,height
  294. ShowEntity plane1 : PositionEntity plane1,0,plane1_y#,0 : ResetEntity plane1
  295. HideEntity plane2
  296. HideEntity main_cam2
  297. HideEntity top_cam2
  298. If no_players=2
  299. game_over2=False
  300. game_over2_delay=0
  301. plane2_x#=0
  302. plane2_z#=0
  303. plane2_ay#=180
  304. plane2_dx#=0
  305. plane2_dz#=0
  306. plane2_day#=180
  307. cam2_x#=0
  308. cam2_z#=0
  309. cam2_ay#=180
  310. cam2_dx#=0
  311. cam2_dz#=0
  312. cam2_day#=180
  313. pot2=0
  314. bank2=0
  315. orange_bonus2_time=0
  316. yellow_bonus2_time=0
  317. green_bonus2_time=0
  318. blue_bonus2_time=0
  319. pink_bonus2_time=0
  320. ; Resize the already active player 1 camera viewport for 2-player game
  321. CameraViewport main_cam1,0,0,width,(height/2)
  322. ShowEntity main_cam2
  323. ShowEntity top_cam2
  324. ShowEntity plane2 : PositionEntity plane2,0,plane2_y#,0 : ResetEntity plane2
  325. EndIf
  326. SetFont large_font
  327. StopChannel music
  328. music=PlayMusic("tune2.mid")
  329. time=MilliSecs()-period
  330. End Function
  331. ; -----------------
  332. ; End game function
  333. ; -----------------
  334. Function EndGame()
  335. For p1.plane1_bullet=Each plane1_bullet
  336. FreeEntity p1\entity
  337. Delete p1
  338. Next
  339. For p2.plane2_bullet=Each plane2_bullet
  340. FreeEntity p2\entity
  341. Delete p2
  342. Next
  343. For u.ufo=Each ufo
  344. FreeEntity u\entity
  345. FreeEntity u\shadow
  346. Delete u
  347. Next
  348. For t.trail=Each trail
  349. FreeEntity t\entity
  350. Delete t
  351. Next
  352. For ub.ufo_bullet=Each ufo_bullet
  353. FreeEntity ub\entity
  354. Delete ub
  355. Next
  356. For b.bullet_trail=Each bullet_trail
  357. FreeEntity b\entity
  358. Delete b
  359. Next
  360. For s.shadow=Each shadow
  361. FreeEntity s\entity
  362. Delete s
  363. Next
  364. For sp.spark=Each spark
  365. FreeEntity sp\entity
  366. Delete sp
  367. Next
  368. For po.points=Each points
  369. FreeEntity po\entity
  370. Delete po
  371. Next
  372. For c.camel=Each camel
  373. FreeEntity c\entity
  374. Delete c
  375. Next
  376. SetFont small_font
  377. StopChannel music
  378. music=PlayMusic("tune1.mid")
  379. FlushKeys
  380. End Function
  381. ; -------------------
  382. ; Load media function
  383. ; -------------------
  384. Function LoadMedia()
  385. ChangeDir "media"
  386. explode=LoadSound("explode.wav")
  387. small_font=LoadFont("courier",16)
  388. large_font=LoadFont("arial black",(width+height)/23.3)
  389. End Function
  390. ; ------------------------
  391. ; Create entities function
  392. ; ------------------------
  393. Function CreateEntities()
  394. ; Create light
  395. light=CreateLight()
  396. RotateEntity light,45,0,0
  397. ; Create main cam 1
  398. main_cam1=CreateCamera()
  399. CameraRange main_cam1,1,9995
  400. CameraFogRange main_cam1,5000,9995
  401. CameraFogMode main_cam1,False
  402. ; Create top cam 1
  403. top_cam1=CreateCamera()
  404. CameraClsColor top_cam1,96,160,248
  405. CameraViewport top_cam1,(width+height)/140,(width+height)/140,(width+height)/8.75,(width+height)/8.75
  406. CameraRange top_cam1,1,1100
  407. MoveEntity top_cam1,0,50,0
  408. TurnEntity top_cam1,90,0,0
  409. ; Create main cam 2
  410. main_cam2=CreateCamera()
  411. CameraViewport main_cam2,0,(height/2),width,(height/2)
  412. CameraRange main_cam2,1,9995
  413. CameraFogRange main_cam2,5000,9995
  414. CameraFogMode main_cam2,1
  415. HideEntity main_cam2
  416. ; Create top cam 2
  417. top_cam2=CreateCamera()
  418. CameraClsColor top_cam2,96,160,248
  419. CameraViewport top_cam2,(width+height)/140,(height/2)+((width+height)/140),(width+height)/8.75,(width+height)/8.75
  420. CameraRange top_cam2,1,1100
  421. MoveEntity top_cam2,0,50,0
  422. TurnEntity top_cam2,90,0,0
  423. HideEntity top_cam2
  424. ; Create ground mesh
  425. ground=CreatePlane()
  426. ; Load sand texture
  427. sand_tex=LoadTexture("sand.bmp")
  428. ScaleTexture sand_tex,100,100
  429. ; Load lights texture
  430. lights_tex=LoadTexture("lights.bmp")
  431. ScaleTexture lights_tex,1000,1000
  432. ; Load lights texture again for multi-texturing purposes
  433. lights_multi_tex=LoadTexture("lights.bmp")
  434. ScaleTexture lights_multi_tex,1000,1000
  435. ; Create ring patterns mesh
  436. ring=CreateMesh()
  437. ring_surf=CreateSurface(ring)
  438. AddVertex(ring_surf,-5000,1,-5000,0,0)
  439. AddVertex(ring_surf,-5000,1,5000,0,1)
  440. AddVertex(ring_surf,5000,1,5000,1,1)
  441. AddVertex(ring_surf,5000,1,-5000,1,0)
  442. AddTriangle(ring_surf,0,1,2)
  443. AddTriangle(ring_surf,0,2,3)
  444. ring_tex=LoadTexture("ring.bmp",3)
  445. EntityTexture ring,ring_tex
  446. EntityFX ring,1
  447. ; Create sky mesh
  448. sky=CreateSphere()
  449. ScaleMesh sky,5000,2750,5000
  450. FlipMesh sky
  451. EntityFX sky,1
  452. EntityOrder sky,1
  453. ; Load sky texture
  454. sky_tex=LoadTexture("clouds.bmp")
  455. ; Load night sky texture
  456. night_sky_tex=LoadTexture("clouds_night.bmp")
  457. ; Load Sphinx mesh
  458. sphinx=LoadMesh("sphinx.x")
  459. EntityShininess sphinx,0.5
  460. EntityType sphinx,type_statue
  461. PositionEntity sphinx,0,90,0
  462. ; Load Statue of Liberty mesh
  463. liberty=LoadMesh("stat_lib.x")
  464. ScaleMesh liberty,10,10,10
  465. EntityType liberty,type_statue
  466. PositionEntity liberty,0,365,0
  467. ; Load plane 1 mesh
  468. plane1=LoadMesh("plane.x")
  469. EntityShininess plane1,1
  470. EntityRadius plane1,2
  471. EntityType plane1,type_plane1
  472. PositionEntity plane1,0,250,0
  473. ResetEntity plane1
  474. ; Create plane 2 mesh - create before shield1 so that shield1 is not copied too
  475. plane2=CopyEntity(plane1)
  476. EntityType plane2,type_plane2
  477. ; Create plane 1 shield mesh
  478. shield1=CreateSphere(16,plane1)
  479. ScaleEntity shield1,10,10,10
  480. EntityColor shield1,0,0,255
  481. EntityShininess shield1,1
  482. ; Create plane 2 shield mesh
  483. shield2=CopyEntity(shield1,plane2)
  484. EntityColor shield2,255,0,0
  485. ; Create debris mesh
  486. debris=CreateMesh()
  487. debris_surf=CreateSurface(debris)
  488. AddVertex(debris_surf,Sin(240)*5,Cos(240)*5,0)
  489. AddVertex(debris_surf,Sin(0)*5,Cos(0)*5,0)
  490. AddVertex(debris_surf,Sin(120)*5,Cos(120)*5,0)
  491. AddVertex(debris_surf,Sin(240)*5,Cos(240)*5,0.001)
  492. AddVertex(debris_surf,Sin(0)*5,Cos(0)*5,0.001)
  493. AddVertex(debris_surf,Sin(120)*5,Cos(120)*5,0.001)
  494. AddTriangle(debris_surf,0,1,2)
  495. AddTriangle(debris_surf,3,5,4)
  496. HideEntity debris
  497. ; Create mother pivot + mesh
  498. mother_pivot=CreatePivot()
  499. PositionEntity mother_pivot,0,1040,0
  500. mother=LoadMesh("mother.x",mother_pivot)
  501. ScaleMesh mother,0.1,0.1,0.1
  502. MoveEntity mother,4880,0,0
  503. ; Load orange ufo mesh
  504. orange_ufo=LoadMesh("orange_ufo.x")
  505. ScaleMesh orange_ufo,20,20,20
  506. EntityShininess orange_ufo,1
  507. EntityRadius orange_ufo,50
  508. EntityType orange_ufo,type_ufo
  509. HideEntity orange_ufo
  510. ; Load yellow ufo mesh
  511. yellow_ufo=LoadMesh("yellow_ufo.x")
  512. ScaleMesh yellow_ufo,20,20,20
  513. EntityShininess yellow_ufo,1
  514. EntityRadius yellow_ufo,50
  515. EntityType yellow_ufo,type_ufo
  516. HideEntity yellow_ufo
  517. ; Load green ufo mesh
  518. green_ufo=LoadMesh("green_ufo.x")
  519. ScaleMesh green_ufo,20,20,20
  520. EntityShininess green_ufo,1
  521. EntityRadius green_ufo,50
  522. EntityType green_ufo,type_ufo
  523. HideEntity green_ufo
  524. ; Load blue ufo mesh
  525. blue_ufo=LoadMesh("blue_ufo.x")
  526. ScaleMesh blue_ufo,20,20,20
  527. EntityShininess blue_ufo,1
  528. EntityRadius blue_ufo,50
  529. EntityType blue_ufo,type_ufo
  530. HideEntity blue_ufo
  531. ; Load pink ufo mesh
  532. pink_ufo=LoadMesh("pink_ufo.x")
  533. ScaleMesh pink_ufo,20,20,20
  534. EntityShininess pink_ufo,1
  535. EntityRadius pink_ufo,50
  536. EntityType pink_ufo,type_ufo
  537. HideEntity pink_ufo
  538. ; Create orange shadow mesh
  539. orange_shadow=CreateMesh()
  540. orange_shadow_surf=CreateSurface(orange_shadow)
  541. AddVertex(orange_shadow_surf,-50,0,-50,0,0)
  542. AddVertex(orange_shadow_surf,-50,0,50,0,1)
  543. AddVertex(orange_shadow_surf,50,0,50,1,1)
  544. AddVertex(orange_shadow_surf,50,0,-50,1,0)
  545. AddTriangle(orange_shadow_surf,0,1,2)
  546. AddTriangle(orange_shadow_surf,0,2,3)
  547. orange_spark_tex=LoadTexture("orange_spark.bmp")
  548. EntityTexture orange_shadow,orange_spark_tex
  549. EntityBlend orange_shadow,3
  550. HideEntity orange_shadow
  551. ; Create yellow shadow mesh
  552. yellow_shadow=CopyEntity(orange_shadow)
  553. yellow_spark_tex=LoadTexture("yellow_spark.bmp")
  554. EntityTexture yellow_shadow,yellow_spark_tex
  555. HideEntity yellow_shadow
  556. ; Create green shadow mesh
  557. green_shadow=CopyEntity(orange_shadow)
  558. green_spark_tex=LoadTexture("green_spark.bmp")
  559. EntityTexture green_shadow,green_spark_tex
  560. HideEntity green_shadow
  561. ; Create blue shadow mesh
  562. blue_shadow=CopyEntity(orange_shadow)
  563. blue_spark_tex=LoadTexture("blue_spark.bmp")
  564. EntityTexture blue_shadow,blue_spark_tex
  565. HideEntity blue_shadow
  566. ; Create pink shadow mesh
  567. pink_shadow=CopyEntity(orange_shadow)
  568. pink_spark_tex=LoadTexture("pink_spark.bmp")
  569. EntityTexture pink_shadow,pink_spark_tex
  570. HideEntity pink_shadow
  571. ; Create orange camel mesh
  572. orange_camel=LoadMesh("camel.x")
  573. ScaleMesh orange_camel,30,30,30
  574. PaintMesh orange_camel,CreateBrush()
  575. EntityColor orange_camel,255,102,0
  576. HideEntity orange_camel
  577. ; Create yellow camel mesh
  578. yellow_camel=CopyEntity(orange_camel)
  579. EntityColor yellow_camel,255,255,0
  580. HideEntity yellow_camel
  581. ; Create green camel mesh
  582. green_camel=CopyEntity(orange_camel)
  583. EntityColor green_camel,0,255,0
  584. HideEntity green_camel
  585. ; Create blue camel mesh
  586. blue_camel=CopyEntity(orange_camel)
  587. EntityColor blue_camel,0,255,255
  588. HideEntity blue_camel
  589. ; Create pink camel mesh
  590. pink_camel=CopyEntity(orange_camel)
  591. EntityColor pink_camel,255,0,255
  592. HideEntity pink_camel
  593. ; Load sun sprite
  594. sun=LoadSprite("big_spark.bmp")
  595. ; Load moon sprite
  596. moon=LoadSprite("moon.bmp",3)
  597. ; Load bullet sprite
  598. bullet=LoadSprite("orange_spark.bmp")
  599. ScaleSprite bullet,10,10
  600. EntityRadius bullet,5
  601. EntityType bullet,type_plane1_bullet
  602. HideEntity bullet
  603. ; Load orange spark sprite - acts as ufo bullet and ufo explosion spark
  604. orange_spark=LoadSprite("orange_spark.bmp")
  605. ScaleSprite orange_spark,10,10
  606. HideEntity orange_spark
  607. ; Load yellow spark sprite - acts as ufo bullet and ufo explosion spark
  608. yellow_spark=LoadSprite("yellow_spark.bmp")
  609. ScaleSprite yellow_spark,10,10
  610. HideEntity yellow_spark
  611. ; Load green spark sprite - acts as ufo bullet and ufo explosion spark
  612. green_spark=LoadSprite("green_spark.bmp")
  613. ScaleSprite green_spark,10,10
  614. HideEntity green_spark
  615. ; Load blue spark sprite - acts as ufo bullet and ufo explosion spark
  616. blue_spark=LoadSprite("blue_spark.bmp")
  617. ScaleSprite blue_spark,10,10
  618. HideEntity blue_spark
  619. ; Load pink spark sprite - acts as ufo bullet and ufo explosion spark
  620. pink_spark=LoadSprite("pink_spark.bmp")
  621. ScaleSprite pink_spark,10,10
  622. HideEntity pink_spark
  623. ; Load 200 points sprite
  624. points_200=LoadSprite("200.bmp",3)
  625. EntityBlend points_200,1
  626. HideEntity points_200
  627. ; Create 200x2 points sprite
  628. points_200x2=LoadSprite("200x2.bmp",3)
  629. EntityBlend points_200x2,1
  630. HideEntity points_200x2
  631. ; Create 200x4 points sprite
  632. points_200x4=LoadSprite("200x4.bmp",3)
  633. EntityBlend points_200x4,1
  634. HideEntity points_200x4
  635. ; Create 200x6 points sprite
  636. points_200x6=LoadSprite("200x6.bmp",3)
  637. EntityBlend points_200x6,1
  638. HideEntity points_200x6
  639. ; Create 200x8 points sprite
  640. points_200x8=LoadSprite("200x8.bmp",3)
  641. EntityBlend points_200x8,1
  642. HideEntity points_200x8
  643. ; Create 200x10 points sprite
  644. points_200x10=LoadSprite("200x10.bmp",3)
  645. EntityBlend points_200x10,1
  646. HideEntity points_200x10
  647. ; Create 400 points sprite
  648. points_400=LoadSprite("400.bmp",3)
  649. EntityBlend points_400,1
  650. HideEntity points_400
  651. ; Create 400x2 points sprite
  652. points_400x2=LoadSprite("400x2.bmp",3)
  653. EntityBlend points_400x2,1
  654. HideEntity points_400x2
  655. ; Create 400x4 points sprite
  656. points_400x4=LoadSprite("400x4.bmp",3)
  657. EntityBlend points_400x4,1
  658. HideEntity points_400x4
  659. ; Create 400x6 points sprite
  660. points_400x6=LoadSprite("400x6.bmp",3)
  661. EntityBlend points_400x6,1
  662. HideEntity points_400x6
  663. ; Create 400x8 points sprite
  664. points_400x8=LoadSprite("400x8.bmp",3)
  665. EntityBlend points_400x8,1
  666. HideEntity points_400x8
  667. ; Create 400x10 points sprite
  668. points_400x10=LoadSprite("400x10.bmp",3)
  669. EntityBlend points_400x10,1
  670. HideEntity points_400x10
  671. ; Create 600 points sprite
  672. points_600=LoadSprite("600.bmp",3)
  673. EntityBlend points_600,1
  674. HideEntity points_600
  675. ; Create 600x2 points sprite
  676. points_600x2=LoadSprite("600x2.bmp",3)
  677. EntityBlend points_600x2,1
  678. HideEntity points_600x2
  679. ; Create 600x4 points sprite
  680. points_600x4=LoadSprite("600x4.bmp",3)
  681. EntityBlend points_600x4,1
  682. HideEntity points_600x4
  683. ; Create 600x6 points sprite
  684. points_600x6=LoadSprite("600x6.bmp",3)
  685. EntityBlend points_600x6,1
  686. HideEntity points_600x6
  687. ; Create 600x8 points sprite
  688. points_600x8=LoadSprite("600x8.bmp",3)
  689. EntityBlend points_600x8,1
  690. HideEntity points_600x8
  691. ; Create 600x10 points sprite
  692. points_600x10=LoadSprite("600x10.bmp",3)
  693. EntityBlend points_600x10,1
  694. HideEntity points_600x10
  695. ; Create 800 points sprite
  696. points_800=LoadSprite("800.bmp",3)
  697. EntityBlend points_800,1
  698. HideEntity points_800
  699. ; Create 800x2 points sprite
  700. points_800x2=LoadSprite("800x2.bmp",3)
  701. EntityBlend points_800x2,1
  702. HideEntity points_800x2
  703. ; Create 800x4 points sprite
  704. points_800x4=LoadSprite("800x4.bmp",3)
  705. EntityBlend points_800x4,1
  706. HideEntity points_800x4
  707. ; Create 800x6 points sprite
  708. points_800x6=LoadSprite("800x6.bmp",3)
  709. EntityBlend points_800x6,1
  710. HideEntity points_800x6
  711. ; Create 800x8 points sprite
  712. points_800x8=LoadSprite("800x8.bmp",3)
  713. EntityBlend points_800x8,1
  714. HideEntity points_800x8
  715. ; Create 800x10 points sprite
  716. points_800x10=LoadSprite("800x10.bmp",3)
  717. EntityBlend points_800x10,1
  718. HideEntity points_800x10
  719. ; Create 1000 points sprite
  720. points_1000=LoadSprite("1000.bmp",3)
  721. EntityBlend points_1000,1
  722. HideEntity points_1000
  723. ; Create 1000x2 points sprite
  724. points_1000x2=LoadSprite("1000x2.bmp",3)
  725. EntityBlend points_1000x2,1
  726. HideEntity points_1000x2
  727. ; Create 1000x4 points sprite
  728. points_1000x4=LoadSprite("1000x4.bmp",3)
  729. EntityBlend points_1000x4,1
  730. HideEntity points_1000x4
  731. ; Create 1000x6 points sprite
  732. points_1000x6=LoadSprite("1000x6.bmp",3)
  733. EntityBlend points_1000x6,1
  734. HideEntity points_1000x6
  735. ; Create 1000x8 points sprite
  736. points_1000x8=LoadSprite("1000x8.bmp",3)
  737. EntityBlend points_1000x8,1
  738. HideEntity points_1000x8
  739. ; Create 1000x10 points sprite
  740. points_1000x10=LoadSprite("1000x10.bmp",3)
  741. EntityBlend points_1000x10,1
  742. HideEntity points_1000x10
  743. ; Create bust points sprite
  744. points_bust=LoadSprite("bust.bmp",3)
  745. EntityBlend points_bust,1
  746. HideEntity points_bust
  747. End Function
  748. ; ------------------------
  749. ; Init collisions function
  750. ; ------------------------
  751. Function InitCollisions()
  752. Collisions type_plane1_bullet,type_ufo,1,1
  753. Collisions type_ufo_bullet,type_plane1,1,1
  754. Collisions type_plane1,type_statue,2,1
  755. Collisions type_plane2_bullet,type_ufo,1,1
  756. Collisions type_ufo_bullet,type_plane2,1,1
  757. Collisions type_plane2,type_statue,2,1
  758. Collisions type_spark,type_ufo,1,1
  759. End Function
  760. ; --------------------
  761. ; Game input1 function
  762. ; --------------------
  763. Function GameInput1()
  764. ; Move up/down
  765. If KeyDown(200)=True Then plane1_dy=plane1_dy+2 : cam1_dy=cam1_dy+2
  766. If KeyDown(208)=True Then plane1_dy=plane1_dy-2 : cam1_dy=cam1_dy-2
  767. ; Turn left/right
  768. If KeyDown(203)=True Then plane1_day=plane1_day+2 : cam1_day=cam1_day+2
  769. If KeyDown(205)=True Then plane1_day=plane1_day-2 : cam1_day=cam1_day-2
  770. ; Move forward - normal
  771. If KeyDown(30)=True And blue_bonus1_status=False
  772. plane1_dx=plane1_dx-Sin(plane1_ay)*8
  773. plane1_dz=plane1_dz+Cos(plane1_ay)*8
  774. cam1_dx=cam1_dx-Sin(cam1_ay)*8
  775. cam1_dz=cam1_dz+Cos(cam1_ay)*8
  776. EndIf
  777. ; Move forward - blue bonus - extra speed
  778. If KeyDown(30)=True And blue_bonus1_status=True
  779. plane1_dx=plane1_dx-Sin(plane1_ay)*16
  780. plane1_dz=plane1_dz+Cos(plane1_ay)*16
  781. cam1_dx=cam1_dx-Sin(cam1_ay)*16
  782. cam1_dz=cam1_dz+Cos(cam1_ay)*16
  783. EndIf
  784. ; Fire bullet - normal
  785. If KeyHit(31)=True And yellow_bonus1_status=False
  786. p1.plane1_bullet=New plane1_bullet
  787. p1\entity=CopyEntity(bullet,plane1)
  788. EntityParent p1\entity,0
  789. TurnEntity p1\entity,0,270,0
  790. MoveEntity p1\entity,0,0,10
  791. p1\alpha=1
  792. EndIf
  793. ; Fire bullet - yellow bonus - rapid fire
  794. yellow_bonus1_pause=yellow_bonus1_pause+1
  795. If KeyDown(31)=True And yellow_bonus1_status=True And yellow_bonus1_pause>=3
  796. yellow_bonus1_pause=0
  797. p1.plane1_bullet=New plane1_bullet
  798. p1\entity=CopyEntity(bullet,plane1)
  799. EntityParent p1\entity,0
  800. TurnEntity p1\entity,0,270,0
  801. MoveEntity p1\entity,0,0,10
  802. p1\alpha=1
  803. EndIf
  804. End Function
  805. ; ----------------------
  806. ; Update plane1 function
  807. ; ----------------------
  808. Function UpdatePlane1()
  809. ; Prevent plane1 and main cam from going too low/high
  810. If plane1_dy<2 Then plane1_dy=2
  811. If plane1_dy>1000 Then plane1_dy=1000
  812. If cam1_dy<2 Then cam1_dy=2
  813. If cam1_dy>1000 Then cam1_dy=1000
  814. ; Update plane1 position/angle values
  815. plane1_x=CurveValue#(plane1_x,plane1_dx,curve_plane)
  816. plane1_y=CurveValue#(plane1_y,plane1_dy,curve_plane)
  817. plane1_z=CurveValue#(plane1_z,plane1_dz,curve_plane)
  818. plane1_ay=CurveValue#(plane1_ay,plane1_day,curve_plane)
  819. PositionEntity plane1,plane1_x,plane1_y,plane1_z
  820. RotateEntity plane1,0,plane1_ay+90,0
  821. ; Update camera1 position values
  822. cam1_x=CurveValue#(cam1_x,cam1_dx,curve_cam)
  823. cam1_y=CurveValue#(cam1_y,cam1_dy,curve_cam)
  824. cam1_z=CurveValue#(cam1_z,cam1_dz,curve_cam)
  825. cam1_ay=CurveValue#(cam1_ay,cam1_day,curve_cam)
  826. PositionEntity main_cam1,plane1_x+Sin(cam1_ay)*50,cam1_y,plane1_z-Cos(cam1_ay)*50
  827. RotateEntity main_cam1,0,cam1_ay,0
  828. PositionEntity top_cam1,plane1_x,plane1_y#+75,plane1_z
  829. RotateEntity top_cam1,90,plane1_ay,0
  830. ; Update plane1 bullets
  831. For p1.plane1_bullet=Each plane1_bullet
  832. MoveEntity p1\entity,0,0,100
  833. If EntityDistance(p1\entity,plane1)>5000 Then FreeEntity p1\entity : Delete p1
  834. Next
  835. ; Check to see if plane1 is inside bank zone and if so bank pot
  836. temp_pivot=CreatePivot()
  837. PositionEntity temp_pivot,red_ring_x,plane1_y,red_ring_z
  838. If EntityDistance(temp_pivot,plane1)<=625 And pot1>0 Then bank1=bank1+pot1 : pot1=0
  839. FreeEntity temp_pivot
  840. End Function
  841. ; -----------------------
  842. ; Update camels1 function
  843. ; -----------------------
  844. Function UpdateCamels1()
  845. For c.camel=Each camel
  846. ; Turn camels, fade them
  847. TurnEntity c\entity,0,2,0
  848. EntityAlpha c\entity,c\alpha : c\alpha=c\alpha-0.0005
  849. ; Use EntityDistance command to check for collision between camel and plane
  850. If EntityDistance(c\entity,plane1)<=40
  851. plane1_bonus=c\colour
  852. c\alpha=0
  853. EndIf
  854. ; Delete camel if invisible
  855. If c\alpha<=0 Then FreeEntity c\entity : Delete c
  856. Next
  857. ; Orange bonus - shield
  858. ; Time
  859. If orange_bonus1_time>300 Then EntityAlpha shield1,0.5 Else EntityAlpha shield1,orange_bonus1_time/600.0
  860. If orange_bonus1_time>0 Then orange_bonus1_time=orange_bonus1_time-1
  861. ; Activate
  862. If plane1_bonus=1
  863. orange_bonus1_status=True
  864. orange_bonus1_time=orange_bonus1_time+600
  865. EntityType plane1,type_none
  866. plane1_bonus=0
  867. EndIf
  868. ; Deactivate
  869. If orange_bonus1_time=0 And orange_bonus1_status=True
  870. orange_bonus1_status=False
  871. EntityType plane1,type_plane1
  872. EndIf
  873. ; Yellow bonus - rapid fire
  874. If yellow_bonus1_time>0 Then yellow_bonus1_time=yellow_bonus1_time-1 ; time
  875. If plane1_bonus=2 Then yellow_bonus1_status=True : yellow_bonus1_time=yellow_bonus1_time+600 : plane1_bonus=0 ; activate
  876. If yellow_bonus1_time=0 And yellow_bonus1_status=True Then yellow_bonus1_status=False ; deactivate
  877. ; Green bonus - homing missiles
  878. If green_bonus1_time>0 Then green_bonus1_time=green_bonus1_time-1 ; time
  879. If plane1_bonus=3 Then green_bonus1_status=True : green_bonus1_time=green_bonus1_time+600 : plane1_bonus=0 ; activate
  880. If green_bonus1_time=0 And green_bonus1_status=True Then green_bonus1_status=False ; deactivate
  881. ; blue bonus - extra speed
  882. If blue_bonus1_time>0 Then blue_bonus1_time=blue_bonus1_time-1 ; time
  883. If plane1_bonus=4 Then blue_bonus1_status=True : blue_bonus1_time=blue_bonus1_time+600 : plane1_bonus=0 ; activate
  884. If blue_bonus1_time=0 And blue_bonus1_status=True Then blue_bonus1_status=False ; deactivate
  885. ; Pink bonus - UFO to rings
  886. If pink_bonus1_time>0 Then pink_bonus1_time=pink_bonus1_time-1 ; time
  887. If plane1_bonus=5 Then pink_bonus1_status=True : pink_bonus1_time=pink_bonus1_time+600 : plane1_bonus=0 ; activate
  888. If pink_bonus1_time=0 And pink_bonus1_status=True Then pink_bonus1_status=False ; deactivate
  889. End Function
  890. ; --------------------------
  891. ; Check collisions1 function
  892. ; --------------------------
  893. Function CheckCollisions1()
  894. ; Ufo and plane1 bullet
  895. For u.ufo=Each ufo
  896. entity_col=EntityCollided(u\entity,type_plane1_bullet)
  897. If entity_col<>0
  898. DeleteBullet1(entity_col)
  899. pot1=pot1+Points(u)
  900. CreateShadow(u) ; Create a new shadow that will reflect explosion sparks after old ufo + shadow have been nuked
  901. ExplodeUFO(u,1)
  902. EndIf
  903. Next
  904. ; Ufo bullet and plane1
  905. If orange_bonus1_status=False
  906. For ub.ufo_bullet=Each ufo_bullet
  907. If EntityCollided(ub\entity,type_plane1)<>0
  908. If pot1>0
  909. pot1=0
  910. FreeEntity ub\entity
  911. Delete ub
  912. po.points=New points
  913. po\entity=CopyEntity(points_bust,plane1)
  914. ShowEntity po\entity
  915. EntityParent po\entity,0
  916. po\alpha=1
  917. Else
  918. game_over1=True
  919. ExplodePlane(plane1)
  920. If no_players=1
  921. HighScore()
  922. EndIf
  923. EndIf
  924. EndIf
  925. Next
  926. EndIf
  927. ; Plane1 and statue
  928. If EntityCollided(plane1,type_statue)<>0 Then game_over1=True : ExplodePlane(plane1) : If no_players=1 Then HighScore()
  929. End Function
  930. ; ----------------------
  931. ; Update mother function
  932. ; ----------------------
  933. Function UpdateMother()
  934. If MilliSecs()-mother_timer=>1000
  935. If no_ufos<max_ufos ; No. ufos limit
  936. ufo_count=ufo_count+1
  937. If ufo_count<=5 Then new_ufo=1 : mother_timer=MilliSecs()
  938. If ufo_count>=6 And ufo_count<=9 Then new_ufo=2 : mother_timer=MilliSecs()
  939. If ufo_count>=10 And ufo_count<=12 Then new_ufo=3 : mother_timer=MilliSecs()
  940. If ufo_count>=13 And ufo_count<=14 Then new_ufo=4 : mother_timer=MilliSecs()
  941. If ufo_count=15 Then new_ufo=5 : ufo_count=0 : mother_timer=MilliSecs()
  942. EndIf
  943. EndIf
  944. TurnEntity mother_pivot,0,0.1,0
  945. End Function
  946. ; -------------------
  947. ; Update ufo function
  948. ; -------------------
  949. Function UpdateUFO()
  950. If new_ufo<>0 Then CreateUFO(new_ufo) : new_ufo=0
  951. For u.ufo=Each ufo
  952. MoveUFO(u)
  953. UFOFire(u)
  954. If MilliSecs()-trail_timer=>500 And u\colour=5 Then CreateTrail(u) : reset_trail_timer=True
  955. Next
  956. If reset_trail_timer=True Then trail_timer=MilliSecs() : reset_trail_timer=False
  957. UFOBullets()
  958. End Function
  959. ; --------------------------
  960. ; Update explosions function
  961. ; --------------------------
  962. Function UpdateExplosions()
  963. ; Explosion sparks
  964. For sp.spark=Each spark
  965. If sp\alpha>0 And EntityY(sp\entity)>-10
  966. EntityAlpha sp\entity,sp\alpha
  967. MoveEntity sp\entity,0,0,4
  968. TranslateEntity sp\entity,0,sp\y_speed,0
  969. sp\alpha=sp\alpha-0.01
  970. sp\y_speed=sp\y_speed-0.1
  971. Else
  972. FreeEntity sp\entity
  973. Delete sp
  974. EndIf
  975. Next
  976. ; Shadows that reflect the sparks
  977. For s.shadow=Each shadow
  978. ScaleEntity s\entity,s\scale,1,s\scale
  979. EntityAlpha s\entity,s\alpha
  980. s\scale=s\scale+0.1
  981. s\alpha=s\alpha-0.01
  982. If s\alpha=<0 Then HideEntity s\entity : FreeEntity s\entity : Delete s
  983. Next
  984. ; Points sprites eg. "200x2"
  985. For po.points=Each points
  986. ScaleSprite po\entity,po\scale,po\scale
  987. EntityAlpha po\entity,po\alpha
  988. po\scale=po\scale+10
  989. po\alpha=po\alpha-0.04
  990. If po\alpha=<0 Then HideEntity po\entity : FreeEntity po\entity : Delete po
  991. Next
  992. End Function
  993. ; ----------------------
  994. ; Update extras function
  995. ; ----------------------
  996. Function UpdateExtras()
  997. If no_players=1
  998. PositionEntity sky,EntityX(main_cam1),0,EntityZ(main_cam1)
  999. PositionEntity solar,EntityX(main_cam1),EntityY(main_cam1)+solar_y,EntityZ(main_cam1)-solar_z
  1000. ScaleSprite solar,Rnd(solar_scale,solar_scale+solar_scale_shake),Rnd(solar_scale,solar_scale+solar_scale_shake)
  1001. EndIf
  1002. End Function
  1003. ; ------------------
  1004. ; Render 2D function
  1005. ; ------------------
  1006. Function Render2D()
  1007. If no_players=1
  1008. Color 255,0,0
  1009. Text (width+height)/140,height-((width+height)/14.5),"Pot: "+pot1+" "
  1010. Color 255,255,255
  1011. Text (width+height)/140,height-((width+height)/24.75),"Bank: "+bank1+" "
  1012. If orange_bonus1_time>0
  1013. Color 255,102,0
  1014. Text width-((width+height)/22.4),0,(orange_bonus1_time/60)+1
  1015. time_y=time_y+(width+height)/31.98
  1016. EndIf
  1017. If yellow_bonus1_time>0
  1018. Color 255,255,0
  1019. Text width-((width+height)/22.4),time_y,(yellow_bonus1_time/60)+1
  1020. time_y=time_y+(width+height)/31.98
  1021. EndIf
  1022. If green_bonus1_time>0
  1023. Color 0,255,0
  1024. Text width-((width+height)/22.4),time_y,(green_bonus1_time/60)+1
  1025. time_y=time_y+(width+height)/31.98
  1026. EndIf
  1027. If blue_bonus1_time>0
  1028. Color 0,255,255
  1029. Text width-((width+height)/22.4),time_y,(blue_bonus1_time/60)+1
  1030. time_y=time_y+(width+height)/31.98
  1031. EndIf
  1032. If pink_bonus1_time>0
  1033. Color 255,0,255
  1034. Text width-((width+height)/22.4),time_y,(pink_bonus1_time/60)+1
  1035. time_y=time_y+(width+height)/31.98
  1036. EndIf
  1037. EndIf
  1038. If no_players=2
  1039. Color 255,0,0
  1040. Text (width+height)/140,(height/2)-((width+height)/14.5),"Pot: "+pot1+" "
  1041. Text (width+height)/140,height-((width+height)/14.5),"Pot: "+pot2+" "
  1042. Color 255,255,255
  1043. Text (width+height)/140,(height/2)-((width+height)/24.75),"Bank: "+bank1+" "
  1044. Text (width+height)/140,height-((width+height)/24.75),"Bank: "+bank2+" "
  1045. ; Player 1 bonus times
  1046. If orange_bonus1_time>0
  1047. Color 255,102,0
  1048. Text width-((width+height)/22.4),time_y,(orange_bonus1_time/60)+1
  1049. time_y=time_y+(width+height)/31.98
  1050. EndIf
  1051. If yellow_bonus1_time>0
  1052. Color 255,255,0
  1053. Text width-((width+height)/22.4),time_y,(yellow_bonus1_time/60)+1
  1054. time_y=time_y+(width+height)/31.98
  1055. EndIf
  1056. If green_bonus1_time>0
  1057. Color 0,255,0
  1058. Text width-((width+height)/22.4),time_y,(green_bonus1_time/60)+1
  1059. time_y=time_y+(width+height)/31.98
  1060. EndIf
  1061. If blue_bonus1_time>0
  1062. Color 0,255,255
  1063. Text width-((width+height)/22.4),time_y,(blue_bonus1_time/60)+1
  1064. time_y=time_y+(width+height)/31.98
  1065. EndIf
  1066. If pink_bonus1_time>0
  1067. Color 255,0,255
  1068. Text width-((width+height)/22.4),time_y,(pink_bonus1_time/60)+1
  1069. time_y=time_y+(width+height)/31.98
  1070. EndIf
  1071. ; Player 2 bonus times
  1072. time_y=height/2
  1073. If orange_bonus2_time>0
  1074. Color 255,102,0
  1075. Text width-((width+height)/22.4),time_y,(orange_bonus2_time/60)+1
  1076. time_y=time_y+(width+height)/31.98
  1077. EndIf
  1078. If yellow_bonus2_time>0
  1079. Color 255,255,0
  1080. Text width-((width+height)/22.4),time_y,(yellow_bonus2_time/60)+1
  1081. time_y=time_y+(width+height)/31.98
  1082. EndIf
  1083. If green_bonus2_time>0
  1084. Color 0,255,0
  1085. Text width-((width+height)/22.4),time_y,(green_bonus2_time/60)+1
  1086. time_y=time_y+(width+height)/31.98
  1087. EndIf
  1088. If blue_bonus2_time>0
  1089. Color 0,255,255
  1090. Text width-((width+height)/22.4),time_y,(blue_bonus2_time/60)+1
  1091. time_y=time_y+(width+height)/31.98
  1092. EndIf
  1093. If pink_bonus2_time>0
  1094. Color 255,0,255
  1095. Text width-((width+height)/22.4),time_y,(pink_bonus2_time/60)+1
  1096. time_y=time_y+(width+height)/31.98
  1097. EndIf
  1098. EndIf
  1099. End Function
  1100. ; -----------------------
  1101. ; Delete bullet1 function
  1102. ; -----------------------
  1103. Function DeleteBullet1(entity_col)
  1104. ; Delete bullet that hits ufo
  1105. For p1.plane1_bullet=Each plane1_bullet
  1106. If p1\entity=entity_col Then FreeEntity p1\entity : Delete p1 : Exit
  1107. Next
  1108. End Function
  1109. ; ----------------------
  1110. ; Explode plane function
  1111. ; ----------------------
  1112. Function ExplodePlane(plane)
  1113. ; Create a new set of sparks
  1114. For t=1 To plane_intensity
  1115. sp.spark=New spark
  1116. sp\y_speed=0
  1117. sp\alpha=2
  1118. sp\entity=CopyEntity(debris,plane)
  1119. EntityParent sp\entity,0
  1120. RotateEntity sp\entity,Rnd(360),Rnd(360),Rnd(360)
  1121. ShowEntity sp\entity
  1122. Next
  1123. ; Hide plane
  1124. HideEntity plane
  1125. ; "BOOM!"
  1126. PlaySound explode
  1127. End Function
  1128. ; -------------------
  1129. ; Create ufo function
  1130. ; -------------------
  1131. Function CreateUfo(new_ufo)
  1132. u.ufo=New ufo
  1133. Select new_ufo
  1134. Case 1 : u\entity=CopyEntity(orange_ufo,mother) : u\shadow=CopyEntity(orange_shadow) : u\colour=1
  1135. Case 2 : u\entity=CopyEntity(yellow_ufo,mother) : u\shadow=CopyEntity(yellow_shadow) : u\colour=2
  1136. Case 3 : u\entity=CopyEntity(green_ufo,mother) : u\shadow=CopyEntity(green_shadow) : u\colour=3
  1137. Case 4 : u\entity=CopyEntity(blue_ufo,mother) : u\shadow=CopyEntity(blue_shadow) : u\colour=4
  1138. Case 5 : u\entity=CopyEntity(pink_ufo,mother) : u\shadow=CopyEntity(pink_shadow) : u\colour=5
  1139. End Select
  1140. EntityParent u\entity,0
  1141. MoveEntity u\entity,0,0,-100
  1142. If no_players=1 Then u\target=plane1
  1143. If no_players=2
  1144. If game_over1<>True And game_over2<>True
  1145. d1#=EntityDistance(u\entity,plane1)
  1146. d2#=EntityDistance(u\entity,plane2)
  1147. If d1#<=d2# Then u\target=plane1 Else u\target=plane2
  1148. Else
  1149. If game_over1=True Then u\target=plane2
  1150. If game_over2=True Then u\target=plane1
  1151. EndIf
  1152. EndIf
  1153. u\x=EntityX(u\entity)
  1154. u\y=EntityY(u\entity)
  1155. u\z=EntityZ(u\entity)
  1156. u\count=179
  1157. no_ufos=no_ufos+1
  1158. End Function
  1159. ; ---------------------
  1160. ; Create trail function
  1161. ; ---------------------
  1162. Function CreateTrail(u.ufo)
  1163. ; New pink ufo trail
  1164. t.trail=New trail
  1165. t\entity=CopyEntity(u\entity)
  1166. EntityType t\entity,type_none
  1167. t\alpha=1
  1168. End Function
  1169. ; -----------------
  1170. ; Move ufo function
  1171. ; -----------------
  1172. Function MoveUFO(u.ufo)
  1173. ; Move UFO towards destination values
  1174. u\count=u\count+1
  1175. u\x=u\x+((u\dx-u\x)/100.0)
  1176. u\y=u\y+((u\dy-u\y)/100.0)
  1177. u\z=u\z+((u\dz-u\z)/100.0)
  1178. PositionEntity u\entity,u\x,u\y,u\z
  1179. PointEntity u\entity,u\target
  1180. TurnEntity u\entity,0,180,0
  1181. RotateEntity u\entity,EntityPitch(u\entity)/2,EntityYaw(u\entity),0
  1182. ; Reset ufo destination values every 180 updates (3 seconds)
  1183. If u\count>=180
  1184. u\count=0
  1185. If pink_bonus1_status=False
  1186. ; Normal
  1187. If u\target=plane1
  1188. u\dx=plane1_x+Rnd(-1500,1500)
  1189. u\dz=plane1_z+Rnd(-1500,1500)
  1190. If plane1_y>=150 Then u\dy=plane1_y+Rnd(-100,100) Else u\dy=plane1_y+Rnd(50,150)
  1191. Else
  1192. u\dx=plane2_x+Rnd(-1500,1500)
  1193. u\dz=plane2_z+Rnd(-1500,1500)
  1194. If plane2_y>=150 Then u\dy=plane2_y+Rnd(-100,100) Else u\dy=plane2_y+Rnd(50,150)
  1195. EndIf
  1196. Else
  1197. ; Pink bonus
  1198. Select u\colour
  1199. Case 1
  1200. u\dx=orange_ring_x+Rnd(-orange_ring_radius,orange_ring_radius)
  1201. u\dz=orange_ring_z+Rnd(-orange_ring_radius,orange_ring_radius)
  1202. Case 2
  1203. u\dx=yellow_ring_x+Rnd(-yellow_ring_radius,yellow_ring_radius)
  1204. u\dz=yellow_ring_z+Rnd(-yellow_ring_radius,yellow_ring_radius)
  1205. Case 3
  1206. u\dx=green_ring_x+Rnd(-green_ring_radius,green_ring_radius)
  1207. u\dz=green_ring_z+Rnd(-green_ring_radius,green_ring_radius)
  1208. Case 4
  1209. u\dx=blue_ring_x+Rnd(-blue_ring_radius,blue_ring_radius)
  1210. u\dz=blue_ring_z+Rnd(-blue_ring_radius,blue_ring_radius)
  1211. Case 5
  1212. u\dx=pink_ring_x+Rnd(-pink_ring_radius,pink_ring_radius)
  1213. u\dz=pink_ring_z+Rnd(-pink_ring_radius,pink_ring_radius)
  1214. End Select
  1215. EndIf
  1216. EndIf
  1217. ; Position shadow
  1218. PositionEntity u\shadow,u\x,1,u\z
  1219. End Function
  1220. ; -----------------
  1221. ; Ufo fire function
  1222. ; -----------------
  1223. Function UFOFire(u.ufo)
  1224. ; Random ufo fire
  1225. If Int(Rnd(0,900))=450
  1226. ub.ufo_bullet=New ufo_bullet
  1227. Select u\colour
  1228. Case 1 : ub\entity=CopyEntity(orange_spark,u\entity)
  1229. Case 2 : ub\entity=CopyEntity(yellow_spark,u\entity)
  1230. Case 3 : ub\entity=CopyEntity(green_spark,u\entity)
  1231. Case 4 : ub\entity=CopyEntity(blue_spark,u\entity)
  1232. Case 5 : ub\entity=CopyEntity(pink_spark,u\entity)
  1233. End Select
  1234. piv=CreatePivot(u\target)
  1235. PointEntity ub\entity,piv
  1236. TurnEntity ub\entity,0,180,0
  1237. FreeEntity piv
  1238. EntityParent ub\entity,0
  1239. EntityType ub\entity,type_ufo_bullet
  1240. EntityRadius ub\entity,5
  1241. ShowEntity ub\entity
  1242. EndIf
  1243. End Function
  1244. ; --------------------
  1245. ; Ufo bullets function
  1246. ; --------------------
  1247. Function UFOBullets()
  1248. ; Update ufo trail
  1249. For t.trail=Each trail
  1250. EntityAlpha t\entity,t\alpha
  1251. t\alpha=t\alpha-0.01
  1252. If t\alpha<=0
  1253. FreeEntity t\entity
  1254. Delete t
  1255. EndIf
  1256. Next
  1257. ; Update ufo bullets
  1258. For ub.ufo_bullet=Each ufo_bullet
  1259. b.bullet_trail=New bullet_trail : b\entity=CopyEntity(ub\entity) : EntityType b\entity,0 : b\alpha=1
  1260. MoveEntity ub\entity,0,0,-20
  1261. If EntityDistance(ub\entity,plane1)>5000 Or EntityY(ub\entity)<=-10 Then FreeEntity ub\entity : Delete ub
  1262. Next
  1263. ; Update ufo bullets trail
  1264. For b.bullet_trail=Each bullet_trail
  1265. b\alpha=b\alpha-0.1
  1266. EntityAlpha b\entity,b\alpha
  1267. If b\alpha<=0 Then FreeEntity b\entity : Delete b
  1268. Next
  1269. End Function
  1270. ; --------------------
  1271. ; Explode ufo function
  1272. ; --------------------
  1273. Function ExplodeUFO(u.ufo,player)
  1274. ; Create a new set of sparks
  1275. For t=1 To ufo_intensity
  1276. sp.spark=New spark
  1277. sp\y_speed=0
  1278. sp\alpha=2
  1279. If u\colour=1 Then sp\entity=CopyEntity(orange_spark,u\entity)
  1280. If u\colour=2 Then sp\entity=CopyEntity(yellow_spark,u\entity)
  1281. If u\colour=3 Then sp\entity=CopyEntity(green_spark,u\entity)
  1282. If u\colour=4 Then sp\entity=CopyEntity(blue_spark,u\entity)
  1283. If u\colour=5 Then sp\entity=CopyEntity(pink_spark,u\entity)
  1284. EntityParent sp\entity,0
  1285. RotateEntity sp\entity,Rnd(360),Rnd(360),Rnd(360)
  1286. If green_bonus1_status=True And player=1
  1287. EntityRadius sp\entity,500
  1288. EntityType sp\entity,type_plane1_bullet
  1289. EndIf
  1290. If green_bonus2_status=True And player=2
  1291. EntityRadius sp\entity,500
  1292. EntityType sp\entity,type_plane2_bullet
  1293. EndIf
  1294. Next
  1295. ; Get rid of ufo
  1296. HideEntity u\entity
  1297. FreeEntity u\entity
  1298. Delete u
  1299. no_ufos=no_ufos-1
  1300. ; "BOOM!"
  1301. PlaySound explode
  1302. End Function
  1303. ; ----------------------
  1304. ; Create shadow function
  1305. ; ----------------------
  1306. Function CreateShadow(u.ufo)
  1307. s.shadow=New shadow
  1308. s\entity=CopyEntity(u\shadow)
  1309. s\scale=1
  1310. s\alpha=1
  1311. HideEntity u\shadow
  1312. FreeEntity u\shadow
  1313. End Function
  1314. ; ---------------
  1315. ; Points function
  1316. ; ---------------
  1317. Function Points(u.ufo)
  1318. Select u\colour
  1319. Case 1 : single=200
  1320. Case 2 : single=400
  1321. Case 3 : single=600
  1322. Case 4 : single=800
  1323. Case 5 : single=1000
  1324. End Select
  1325. temp_pivot=CreatePivot()
  1326. multi=1
  1327. PositionEntity temp_pivot,red_ring_x,u\y,red_ring_z : If EntityDistance(temp_pivot,u\entity)<=red_ring_radius Then multi=0
  1328. PositionEntity temp_pivot,orange_ring_x,u\y,orange_ring_z : If EntityDistance(temp_pivot,u\entity)<=orange_ring_radius Then multi=2
  1329. PositionEntity temp_pivot,yellow_ring_x,u\y,yellow_ring_z : If EntityDistance(temp_pivot,u\entity)<=yellow_ring_radius Then multi=4
  1330. PositionEntity temp_pivot,green_ring_x,u\y,green_ring_z : If EntityDistance(temp_pivot,u\entity)<=green_ring_radius Then multi=6
  1331. PositionEntity temp_pivot,blue_ring_x,u\y,blue_ring_z : If EntityDistance(temp_pivot,u\entity)<=blue_ring_radius Then multi=8
  1332. PositionEntity temp_pivot,pink_ring_x,u\y,pink_ring_z : If EntityDistance(temp_pivot,u\entity)<=pink_ring_radius Then multi=10
  1333. points=single*multi
  1334. If multi=0 Then points=0 : po.points=New points : po\entity=CopyEntity(points_bust,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1335. If single=200 And multi=1 Then po.points=New points : po\entity=CopyEntity(points_200,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1336. If single=200 And multi=2 Then po.points=New points : po\entity=CopyEntity(points_200x2,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2 : c.camel=New camel : c\entity=CopyEntity(orange_camel,u\entity) : EntityParent c\entity,0 : c\colour=1 : c\alpha=1
  1337. If single=200 And multi=4 Then po.points=New points : po\entity=CopyEntity(points_200x4,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1338. If single=200 And multi=6 Then po.points=New points : po\entity=CopyEntity(points_200x6,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1339. If single=200 And multi=8 Then po.points=New points : po\entity=CopyEntity(points_200x8,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1340. If single=200 And multi=10 Then po.points=New points : po\entity=CopyEntity(points_200x10,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1341. If single=400 And multi=1 Then po.points=New points : po\entity=CopyEntity(points_400,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1342. If single=400 And multi=2 Then po.points=New points : po\entity=CopyEntity(points_400x2,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1343. If single=400 And multi=4 Then po.points=New points : po\entity=CopyEntity(points_400x4,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2 : c.camel=New camel : c\entity=CopyEntity(yellow_camel,u\entity) : EntityParent c\entity,0 : c\colour=2 : c\alpha=1
  1344. If single=400 And multi=6 Then po.points=New points : po\entity=CopyEntity(points_400x6,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1345. If single=400 And multi=8 Then po.points=New points : po\entity=CopyEntity(points_400x8,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1346. If single=400 And multi=10 Then po.points=New points : po\entity=CopyEntity(points_400x10,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1347. If single=600 And multi=1 Then po.points=New points : po\entity=CopyEntity(points_600,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1348. If single=600 And multi=2 Then po.points=New points : po\entity=CopyEntity(points_600x2,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1349. If single=600 And multi=4 Then po.points=New points : po\entity=CopyEntity(points_600x4,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1350. If single=600 And multi=6 Then po.points=New points : po\entity=CopyEntity(points_600x6,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2 : c.camel=New camel : c\entity=CopyEntity(green_camel,u\entity) : EntityParent c\entity,0 : c\colour=3 : c\alpha=1
  1351. If single=600 And multi=8 Then po.points=New points : po\entity=CopyEntity(points_600x8,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1352. If single=600 And multi=10 Then po.points=New points : po\entity=CopyEntity(points_600x10,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1353. If single=800 And multi=1 Then po.points=New points : po\entity=CopyEntity(points_800,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1354. If single=800 And multi=2 Then po.points=New points : po\entity=CopyEntity(points_800x2,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1355. If single=800 And multi=4 Then po.points=New points : po\entity=CopyEntity(points_800x4,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1356. If single=800 And multi=6 Then po.points=New points : po\entity=CopyEntity(points_800x6,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1357. If single=800 And multi=8 Then po.points=New points : po\entity=CopyEntity(points_800x8,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2 : c.camel=New camel : c\entity=CopyEntity(blue_camel,u\entity) : EntityParent c\entity,0 : c\colour=4 : c\alpha=1
  1358. If single=800 And multi=10 Then po.points=New points : po\entity=CopyEntity(points_800x10,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1359. If single=1000 And multi=1 Then po.points=New points : po\entity=CopyEntity(points_1000,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1360. If single=1000 And multi=2 Then po.points=New points : po\entity=CopyEntity(points_1000x2,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1361. If single=1000 And multi=4 Then po.points=New points : po\entity=CopyEntity(points_1000x4,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1362. If single=1000 And multi=6 Then po.points=New points : po\entity=CopyEntity(points_1000x6,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1363. If single=1000 And multi=8 Then po.points=New points : po\entity=CopyEntity(points_1000x8,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2
  1364. If single=1000 And multi=10 Then po.points=New points : po\entity=CopyEntity(points_1000x10,u\entity) : ShowEntity po\entity : EntityParent po\entity,0 : po\alpha=2 : c.camel=New camel : c\entity=CopyEntity(pink_camel,u\entity) : EntityParent c\entity,0 : c\colour=5 : c\alpha=1
  1365. FreeEntity temp_pivot
  1366. Return points
  1367. End Function
  1368. ; -------------------
  1369. ; High score function
  1370. ; -------------------
  1371. Function HighScore()
  1372. ; Load high score data
  1373. load_file=ReadFile("high_scores.sav")
  1374. For s=1 To 10
  1375. names$(s)=ReadLine(load_file)
  1376. scores(s)=ReadLine(load_file)
  1377. Next
  1378. CloseFile load_file
  1379. ; Insert high score
  1380. player_name$=""
  1381. rank=1
  1382. While bank1<scores(rank) ; scores(11) = zero value so score will never be lower than that, so rank = 11 max
  1383. rank=rank+1
  1384. Wend
  1385. If rank<=10 ; If score is high enough to get on high score table
  1386. For s=10 To rank Step -1
  1387. scores(s)=scores(s-1)
  1388. names$(s)=names$(s-1)
  1389. Next
  1390. names$(rank)=player_name$
  1391. scores(rank)=bank1
  1392. screen=6
  1393. option=1
  1394. EndIf
  1395. ; Save high score data
  1396. save_file=WriteFile("high_scores.sav")
  1397. For s=1 To 10
  1398. WriteLine save_file,names$(s)
  1399. WriteLine save_file,scores(s)
  1400. Next
  1401. CloseFile save_file
  1402. End Function
  1403. ;---------------------
  1404. ; Curve value function
  1405. ;---------------------
  1406. Function CurveValue#(current#,destination#,curve)
  1407. current#=current#+((destination#-current#)/curve)
  1408. Return current#
  1409. End Function