Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Conditional Hooks
- $State: GS_STATE_GAME_PLAY
- $On Frame:
- [
- if booleanInitScroll == true then
- objectPlayer = hv.Player
- if objectPlayer:isValid() then --Player Validity Check
- --Get Position and Orientation and Speed
- vectorCurrentPos = objectPlayer.Position
- local x = gr.getVectorFromCoords(vectorCurrentPos["x"],vectorCurrentPos["y"],vectorCurrentPos["z"],false)
- local lx,ly = x:getScreenCoords()
- --ba.error(type(x:getScreenCoords()))
- if lx < 0 then
- x = gr.getVectorFromCoords(0,0)
- --s:getScreenCoords()/getScreenCoords()["x"]
- vectorCurrentPos["z"] = x["x"]
- elseif lx > gr.getScreenWidth() then
- x = gr.getVectorFromCoords(gr.getScreenWidth,0)
- vectorCurrentPos["z"] = x["x"]
- end
- --AndrewofDoom's mod: addition of scrolling
- if booleanInitScroll == true then --double check to see if this still is really true.
- local ft = ba.getFrametime(false)
- intSavedCamPosX = intSavedCamPosX + (floatScrollX)
- intSavedCamPosY = intSavedCamPosY + (floatScrollY)
- intSavedCamPosZ = intSavedCamPosZ + (floatScrollZ)
- vectorCCameraPos = ba.createVector(intSavedCamPosX,intSavedCamPosY,intSavedCamPosZ)
- objectCCamera:setPosition(vectorCCameraPos)
- --gr.setCamera(objectCCamera)
- ---Keep player moving relative to camera
- vectorCurrentPos["x"] = vectorCurrentPos["x"] + (floatScrollX)
- vectorCurrentPos["y"] = vectorCurrentPos["y"] + (floatScrollY)
- vectorCurrentPos["z"] = vectorCurrentPos["z"] + (floatScrollZ)
- objectPlayer.Position = vectorCurrentPos
- end
- end --Player Validity Check
- end
- function initShmup()
- ---Create 'blank' orientation
- ---these rotations are in RADIANS, not degrees.
- orientationBlank = mn.Ships[1].Orientation
- orientationBlank["p"] = 0
- orientationBlank["b"] = 0
- orientationBlank["h"] = -1.57
- intSavedCamPosX = 250
- intSavedCamPosY = 0
- intSavedCamPosZ = 0
- ---Scroll rates for each axis
- floatScrollX = 0
- floatScrollY = 0
- floatScrollZ = 0.5
- vectorCCameraPos = ba.createVector(intSavedCamPosX,intSavedCamPosY,intSavedCamPosZ)
- orientationCCamera = orientationBlank
- ---Create chase camera
- objectCCamera = gr.createCamera("Chase Camera",vectorCCameraPos,orientationCCamera)
- ---Use the new chase camera
- gr.setCamera(objectCCamera)
- booleanInitScroll = true
- end
- ---Modifies the scroll speed of the camera on any axes a man desires..
- function setScrollSpeed(x,y,z)
- floatScrollX = x
- floatScrollY = y
- floatScrollZ = z
- end
- ---Sets the current Status of the camera scrolling. initShmup must be called first to avoid funny stuff from happening.
- ---True turns it on, false to turn it off and rest the camera view to the player ship.
- function setScrollingActive(booleanSwitch)
- if booleanSwitch == true then
- vectorCCameraPos = ba.createVector((objectPlayer.Position["x"]-250),objectPlayer.Position["y"],objectPlayer.Position["z"])
- objectCCamera:setPosition(vectorCCameraPos)
- gr.setCamera(objectCCamera)
- booleanInitScroll = true
- else
- --Disable camera and scrolling, probably for a cutscene or something of that matter.
- booleanInitScroll = false
- gr.setCamera()
- end
- end
- ]
- #End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement