Advertisement
AndrewofDoom

Untitled

Jun 20th, 2012
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. #Conditional Hooks
  2.  
  3. $State: GS_STATE_GAME_PLAY
  4.  
  5. $On Frame:
  6.  
  7. [
  8. if booleanInitScroll == true then
  9.  
  10. objectPlayer = hv.Player
  11.  
  12. if objectPlayer:isValid() then --Player Validity Check
  13.  
  14. --Get Position and Orientation and Speed
  15. vectorCurrentPos = objectPlayer.Position
  16.  
  17. local x = gr.getVectorFromCoords(vectorCurrentPos["x"],vectorCurrentPos["y"],vectorCurrentPos["z"],false)
  18. local lx,ly = x:getScreenCoords()
  19. --ba.error(type(x:getScreenCoords()))
  20. if lx < 0 then
  21. x = gr.getVectorFromCoords(0,0)
  22. --s:getScreenCoords()/getScreenCoords()["x"]
  23. vectorCurrentPos["z"] = x["x"]
  24. elseif lx > gr.getScreenWidth() then
  25. x = gr.getVectorFromCoords(gr.getScreenWidth,0)
  26. vectorCurrentPos["z"] = x["x"]
  27. end
  28.  
  29. --AndrewofDoom's mod: addition of scrolling
  30. if booleanInitScroll == true then --double check to see if this still is really true.
  31. local ft = ba.getFrametime(false)
  32. intSavedCamPosX = intSavedCamPosX + (floatScrollX)
  33. intSavedCamPosY = intSavedCamPosY + (floatScrollY)
  34. intSavedCamPosZ = intSavedCamPosZ + (floatScrollZ)
  35. vectorCCameraPos = ba.createVector(intSavedCamPosX,intSavedCamPosY,intSavedCamPosZ)
  36. objectCCamera:setPosition(vectorCCameraPos)
  37. --gr.setCamera(objectCCamera)
  38. ---Keep player moving relative to camera
  39. vectorCurrentPos["x"] = vectorCurrentPos["x"] + (floatScrollX)
  40. vectorCurrentPos["y"] = vectorCurrentPos["y"] + (floatScrollY)
  41. vectorCurrentPos["z"] = vectorCurrentPos["z"] + (floatScrollZ)
  42. objectPlayer.Position = vectorCurrentPos
  43. end
  44. end --Player Validity Check
  45. end
  46.  
  47. function initShmup()
  48.  
  49. ---Create 'blank' orientation
  50. ---these rotations are in RADIANS, not degrees.
  51. orientationBlank = mn.Ships[1].Orientation
  52. orientationBlank["p"] = 0
  53. orientationBlank["b"] = 0
  54. orientationBlank["h"] = -1.57
  55.  
  56. intSavedCamPosX = 250
  57. intSavedCamPosY = 0
  58. intSavedCamPosZ = 0
  59. ---Scroll rates for each axis
  60. floatScrollX = 0
  61. floatScrollY = 0
  62. floatScrollZ = 0.5
  63. vectorCCameraPos = ba.createVector(intSavedCamPosX,intSavedCamPosY,intSavedCamPosZ)
  64. orientationCCamera = orientationBlank
  65.  
  66. ---Create chase camera
  67. objectCCamera = gr.createCamera("Chase Camera",vectorCCameraPos,orientationCCamera)
  68.  
  69. ---Use the new chase camera
  70. gr.setCamera(objectCCamera)
  71.  
  72. booleanInitScroll = true
  73. end
  74.  
  75. ---Modifies the scroll speed of the camera on any axes a man desires..
  76. function setScrollSpeed(x,y,z)
  77. floatScrollX = x
  78. floatScrollY = y
  79. floatScrollZ = z
  80. end
  81.  
  82. ---Sets the current Status of the camera scrolling. initShmup must be called first to avoid funny stuff from happening.
  83. ---True turns it on, false to turn it off and rest the camera view to the player ship.
  84. function setScrollingActive(booleanSwitch)
  85. if booleanSwitch == true then
  86. vectorCCameraPos = ba.createVector((objectPlayer.Position["x"]-250),objectPlayer.Position["y"],objectPlayer.Position["z"])
  87. objectCCamera:setPosition(vectorCCameraPos)
  88. gr.setCamera(objectCCamera)
  89. booleanInitScroll = true
  90. else
  91. --Disable camera and scrolling, probably for a cutscene or something of that matter.
  92. booleanInitScroll = false
  93. gr.setCamera()
  94. end
  95. end
  96.  
  97. ]
  98.  
  99. #End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement