player2.bb 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. ; Exact replicas of player 1 functions but for player 2
  2. ; -----------
  3. ; Game Input2
  4. ; -----------
  5. Function GameInput2()
  6. ; Move up/down
  7. If JoyYDir()=-1 Then plane2_dy=plane2_dy+2 : cam2_dy=cam2_dy+2
  8. If JoyYDir()=1 Then plane2_dy=plane2_dy-2 : cam2_dy=cam2_dy-2
  9. ; Turn left/right
  10. If JoyXDir()=-1 Then plane2_day=plane2_day+2 : cam2_day=cam2_day+2
  11. If JoyXDir()=1 Then plane2_day=plane2_day-2 : cam2_day=cam2_day-2
  12. ; Move forward - normal
  13. If JoyDown(3)=True And blue_bonus2_status=False
  14. plane2_dx=plane2_dx-Sin(plane2_ay)*8
  15. plane2_dz=plane2_dz+Cos(plane2_ay)*8
  16. cam2_dx=cam2_dx-Sin(cam2_ay)*8
  17. cam2_dz=cam2_dz+Cos(cam2_ay)*8
  18. EndIf
  19. ; Move forward - blue bonus - extra speed
  20. If JoyDown(3)=True And blue_bonus2_status=True
  21. plane2_dx=plane2_dx-Sin(plane2_ay)*16
  22. plane2_dz=plane2_dz+Cos(plane2_ay)*16
  23. cam2_dx=cam2_dx-Sin(cam2_ay)*16
  24. cam2_dz=cam2_dz+Cos(cam2_ay)*16
  25. EndIf
  26. ; Fire bullet - normal
  27. If JoyHit(1)=True And rapid_fire_status2=False
  28. p2.plane2_bullet=New plane2_bullet
  29. p2\entity=CopyEntity(bullet,plane2)
  30. EntityType p2\entity,type_plane2_bullet
  31. EntityParent p2\entity,0
  32. TurnEntity p2\entity,0,270,0
  33. MoveEntity p2\entity,0,0,10
  34. p2\alpha=1
  35. EndIf
  36. ; Fire bullet - yellow bonus - rapid fire
  37. yellow_bonus2_pause=yellow_bonus2_pause+1
  38. If JoyDown(1)=True And yellow_bonus2_status=True And yellow_bonus2_pause>=3
  39. yellow_bonus2_pause=0
  40. p2.plane2_bullet=New plane2_bullet
  41. p2\entity=CopyEntity(bullet,plane2)
  42. EntityType p2\entity,type_plane2_bullet
  43. EntityParent p2\entity,0
  44. TurnEntity p2\entity,0,270,0
  45. MoveEntity p2\entity,0,0,10
  46. p2\alpha=1
  47. EndIf
  48. End Function
  49. ; ----------------------
  50. ; Update plane2 function
  51. ; ----------------------
  52. Function UpdatePlane2()
  53. ; Prevent plane2 and main cam from going too low/high
  54. If plane2_dy<2 Then plane2_dy=2
  55. If plane2_dy>1000 Then plane2_dy=1000
  56. If cam2_dy<2 Then cam2_dy=2
  57. If cam2_dy>1000 Then cam2_dy=1000
  58. ; Update plane2 position/angle values
  59. plane2_x=plane2_x+((plane2_dx-plane2_x)/curve_plane)
  60. plane2_y=plane2_y+((plane2_dy-plane2_y)/curve_plane)
  61. plane2_z=plane2_z+((plane2_dz-plane2_z)/curve_plane)
  62. plane2_ay=plane2_ay+((plane2_day-plane2_ay)/curve_plane)
  63. PositionEntity plane2,plane2_x,plane2_y,plane2_z
  64. RotateEntity plane2,0,plane2_ay+90,0
  65. ; Update camera2 position values
  66. cam2_x=cam2_x+((cam2_dx-cam2_x)/curve_cam)
  67. cam2_y=cam2_y+((cam2_dy-cam2_y)/curve_cam)
  68. cam2_z=cam2_z+((cam2_dz-cam2_z)/curve_cam)
  69. cam2_ay=cam2_ay+((cam2_day-cam2_ay)/curve_cam)
  70. PositionEntity main_cam2,plane2_x+Sin(cam2_ay)*50,cam2_y,plane2_z-Cos(cam2_ay)*50
  71. RotateEntity main_cam2,0,cam2_ay,0
  72. PositionEntity top_cam2,plane2_x,plane2_y#+75,plane2_z
  73. RotateEntity top_cam2,90,plane2_ay,0
  74. ; Update plane2 bullets
  75. For p2.plane2_bullet=Each plane2_bullet
  76. MoveEntity p2\entity,0,0,100
  77. If EntityDistance(p2\entity,plane2)>5000 Then FreeEntity p2\entity : Delete p2
  78. Next
  79. ; Check to see if plane2 is inside bank zone and if so bank pot
  80. temp_pivot=CreatePivot()
  81. PositionEntity temp_pivot,red_ring_x,plane2_y,red_ring_z
  82. If EntityDistance(temp_pivot,plane2)<=625 And pot2>0 Then bank2=bank2+pot2 : pot2=0
  83. FreeEntity temp_pivot
  84. End Function
  85. ; -----------------------
  86. ; Update Camels2 function
  87. ; -----------------------
  88. Function UpdateCamels2()
  89. For c.camel=Each camel
  90. ; Turn camels, fade them
  91. TurnEntity c\entity,0,2,0
  92. EntityAlpha c\entity,c\alpha : c\alpha=c\alpha-0.0005
  93. ; Use EntityDistance command to check for collision between camel and plane
  94. If EntityDistance(c\entity,plane2)<=40
  95. plane2_bonus=c\colour
  96. c\alpha=0
  97. EndIf
  98. ; Delete camel if invisible
  99. If c\alpha<=0 Then FreeEntity c\entity : Delete c
  100. Next
  101. ; Orange bonus - shield
  102. ; Time
  103. If orange_bonus2_time>300 Then EntityAlpha shield2,0.5 Else EntityAlpha shield2,orange_bonus2_time/600.0
  104. If orange_bonus2_time>0 Then orange_bonus2_time=orange_bonus2_time-1
  105. ; Activate
  106. If plane2_bonus=1
  107. orange_bonus2_status=True
  108. orange_bonus2_time=orange_bonus2_time+600
  109. EntityType plane2,type_none
  110. plane2_bonus=0
  111. EndIf
  112. ; Deactivate
  113. If orange_bonus2_time=0 And orange_bonus2_status=True
  114. orange_bonus2_status=False
  115. EntityType plane2,type_plane2
  116. EndIf
  117. ; Yellow bonus - rapid fire
  118. If yellow_bonus2_time>0 Then yellow_bonus2_time=yellow_bonus2_time-1 ; time
  119. If plane2_bonus=2 Then yellow_bonus2_status=True : yellow_bonus2_time=yellow_bonus2_time+600 : plane2_bonus=0 ; activate
  120. If yellow_bonus2_time=0 And yellow_bonus2_status=True Then yellow_bonus2_status=False ; deactivate
  121. ; Green bonus - homing missiles
  122. If green_bonus2_time>0 Then green_bonus2_time=green_bonus2_time-1 ; time
  123. If plane2_bonus=3 Then green_bonus2_status=True : green_bonus2_time=green_bonus2_time+600 : plane2_bonus=0 ; activate
  124. If green_bonus2_time=0 And green_bonus2_status=True Then green_bonus2_status=False ; deactivate
  125. ; Turquoise bonus - extra speed
  126. If blue_bonus2_time>0 Then blue_bonus2_time=blue_bonus2_time-1 ; time
  127. If plane2_bonus=4 Then blue_bonus2_status=True : blue_bonus2_time=blue_bonus2_time+600 : plane2_bonus=0 ; activate
  128. If blue_bonus2_time=0 And blue_bonus2_status=True Then blue_bonus2_status=False ; deactivate
  129. ; Pink bonus - UFO to rings
  130. If pink_bonus2_time>0 Then pink_bonus2_time=pink_bonus2_time-1 ; time
  131. If plane2_bonus=5 Then pink_bonus2_status=True : pink_bonus2_time=pink_bonus2_time+600 : plane2_bonus=0 ; activate
  132. If pink_bonus2_time=0 And pink_bonus2_status=True Then pink_bonus2_status=False ; deactivate
  133. End Function
  134. ; --------------------------
  135. ; Check Collisions2 function
  136. ; --------------------------
  137. Function CheckCollisions2()
  138. ; Ufo and plane2 bullet
  139. For u.ufo=Each ufo
  140. entity_col=EntityCollided(u\entity,type_plane2_bullet)
  141. If entity_col<>0
  142. DeleteBullet2(entity_col)
  143. pot2=pot2+Points(u)
  144. CreateShadow(u) ; Create a new shadow that will reflect explosion sparks after old ufo + shadow have been nuked
  145. ExplodeUfo(u,2)
  146. EndIf
  147. Next
  148. ; Ufo bullet and plane2
  149. If orange_bonus2_status=False
  150. For ub.ufo_bullet=Each ufo_bullet
  151. If EntityCollided(ub\entity,type_plane2)<>0
  152. If pot2>0
  153. pot2=0
  154. FreeEntity ub\entity
  155. Delete ub
  156. po.points=New points
  157. po\entity=CopyEntity(points_bust,plane2)
  158. ShowEntity po\entity
  159. EntityParent po\entity,0
  160. po\alpha=1
  161. Else
  162. game_over2=True
  163. ExplodePlane(plane2)
  164. EndIf
  165. EndIf
  166. Next
  167. EndIf
  168. ; Plane2 and statue
  169. If EntityCollided(plane2,type_statue)<>0 Then game_over2=True : ExplodePlane(plane2)
  170. End Function
  171. ; -----------------------
  172. ; Delete Bullet2 function
  173. ; -----------------------
  174. Function DeleteBullet2(entity_col)
  175. ; Delete bullet that hits ufo
  176. For p2.plane2_bullet=Each plane2_bullet
  177. If p2\entity=entity_col Then FreeEntity p2\entity : Delete p2 : Exit
  178. Next
  179. End Function