Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Main loop that begins once initShmup() is executed.
- if booleanInitScroll == true then
- if objectPlayer:isValid() then --Player Validity Check
- hv.Player.CollisionGroups = 1
- --Keep the play on the same X coordinate as the camera.
- local posX = ship_central_camera.Position["x"]
- local constPos = ba.createVector(posX,objectPlayer.Position["y"],objectPlayer.Position["z"])
- objectPlayer.Position = constPos
- ft = ba.getFrametime(false)
- --Horizontal Position Limit
- if objectPlayer.Position["x"] > floatHLimit then
- local playPos = ba.createVector((floatHLimit - 1), objectPlayer.Position["y"], objectPlayer.Position["z"])
- objectPlayer.Position = playPos
- elseif objectPlayer.Position["x"] < floatHRLimit then
- local playPos = ba.createVector((floatHRLimit + 1), objectPlayer.Position["y"], objectPlayer.Position["z"])
- objectPlayer.Position = playPos
- end
- --Vertical Position Limit
- if objectPlayer.Position["y"] > floatVLimit then
- local playPos = ba.createVector(objectPlayer.Position["x"],(floatVLimit - 1), objectPlayer.Position["z"])
- objectPlayer.Position = playPos
- elseif objectPlayer.Position["y"] < floatVRLimit then
- local playPos = ba.createVector(objectPlayer.Position["x"],(floatVRLimit + 1), objectPlayer.Position["z"])
- objectPlayer.Position = playPos
- end
- --Forward Position Limit
- if objectPlayer.Position["z"] > floatFLimit then
- local playPos = ba.createVector(objectPlayer.Position["x"],objectPlayer.Position["y"],(floatFLimit - 1))
- objectPlayer.Position = playPos
- elseif objectPlayer.Position["z"] < floatFRLimit then
- local playPos = ba.createVector(objectPlayer.Position["x"],objectPlayer.Position["y"],(floatFRLimit + 1))
- objectPlayer.Position = playPos
- end
- --AndrewofDoom's mod: addition of scrolling
- if booleanInitScroll == true then --double check to see if this still is really true.
- intSavedCamPosX = intSavedCamPosX + (floatScrollX*ft)
- intSavedCamPosY = intSavedCamPosY + (floatScrollY*ft)
- intSavedCamPosZ = intSavedCamPosZ + (floatScrollZ*ft)
- vectorCCameraPos = ba.createVector(intSavedCamPosX,intSavedCamPosY,intSavedCamPosZ)
- objectCCamera:setPosition(vectorCCameraPos)
- gr.setCamera(objectCCamera)
- floatHLimit = floatHLimit + (floatScrollX*ft)
- floatVLimit = floatVLimit + (floatScrollY*ft)
- floatFLimit = floatFLimit + (floatScrollZ*ft)
- ---Set movement limits again for the rear. The original version makes the assumption that the player's postion will be along the origin and thus symmetrical, which will not be the case if the camera is scrolling.
- floatHRLimit = floatHRLimit + (floatScrollX*ft)
- floatVRLimit = floatVRLimit + (floatScrollY*ft)
- floatFRLimit = floatFRLimit + (floatScrollZ*ft)
- --all scrolling related to slaved ships.
- if slaveShips ~= nil then
- for i=1,#slaveShips do
- local scrollS = slaveShips[i]
- if scrollS ~= nil then --If this ship is null, don't bother playing with it.
- local pos = scrollS.Position
- if slaveToX[i] == true then
- pos["x"] = pos["x"] + (floatScrollX*ft)
- end
- if slaveToY[i] == true then
- pos["y"] = pos["y"] + (floatScrollY*ft)
- end
- if slaveToZ[i] == true then
- pos["z"] = pos["z"] + (floatScrollZ*ft)
- end
- scrollS.Position = pos
- slaveShips[i] = scrollS
- end
- end
- end
- ---enforce projectile positions relative to scrolling and cull offscreen projectiles firing from the player or targetting the player.
- local numWeps = #mn.Weapons
- for i=1,numWeps do
- local wep = mn.Weapons[i]
- local wPos = wep.Position
- if wep.Parent == hv.Player or wep.Target == hv.Player then
- --Check for out of bounds
- if (wPos["y"] > floatVLimit or wPos["y"] < floatVRLimit or wPos["z"] > floatFLimit or wPos["z"] < floatFRLimit) and not(wep.Target == hv.Player and ((wep.Parent.Position["x"]+100) < hv.Player.Position["x"] or (wep.Parent.Position["x"]-100) > hv.Player.Position["x"])) then
- wep.LifeLeft = 0.0 --Terminate weapon
- end
- if wep.LifeLeft > 0 then
- --if still in bounds, apply scrolling.
- wPos["x"] = wPos["x"] + (floatScrollX*ft)
- if wep.Parent == hv.Player then
- wPos["y"] = wPos["y"] + (floatScrollY*ft)
- wPos["z"] = wPos["z"] + (floatScrollZ*ft)
- end
- wep.Position = wPos
- end
- end
- if wep.LifeLeft > 0 then --if this projectile is dead, then don't bother.
- --force these projectiles from these ships to have their scrolling force to player position and 0'd x component velocities.
- --May seem like an ugly O(n^2) algorithm, but this stuff is usually reserved for important enemies. Namely, bosses which are usually one, MAYBE two, in count.
- for j=1, #forcedProjShipsToPlayerAxis do
- if forcedProjShipsToPlayerAxis[j] ~= nil then --if there is no one here, then don't bother.
- if wep.Parent == forcedProjShipsToPlayerAxis[j] then
- local wepPos = ba.createVector(objectPlayer.Position["x"],wep.Position["y"],wep.Position["z"])
- wep.Position = wepPos
- local wepVel = ba.createVector(0,wep.Physics.Velocity["y"],wep.Physics.Velocity["z"])
- wep.Physics.Velocity = wepVel
- wep.Physics.VelocityDesired = wepVel
- wep.Physics.VelocityMax = wepVel
- local wepOrient = ba.createOrientation(wep.Orientation["p"],wep.Orientation["b"],0.0)
- wep.Orientation = wepOrient
- end
- end
- end
- end
- mn.Weapons[i] = wep --Apply weapon change
- end
- end
- --Force the player's "scroll speed" to be a minimum velocity because LOLCOLLISIONDETECTION requires at least one of the pair to have a velocity =/= 0
- local diffToApplyX = (floatScrollX*59*ft*(5/3))/(1-ft) --This equation is able to compensate for shitty computers. I've tested it at 20 FPS up to 60 FPS. If you get less than 20, you prolly shouldn't be playing this anyway.
- local diffToApplyY = (floatScrollY*59*ft*(5/3))/(1-ft)
- local diffToApplyZ = (floatScrollZ*59*ft*(5/3))/(1-ft)
- shmup_idle_pscroll_speed = ba.createVector((diffToApplyX),(diffToApplyY),(diffToApplyZ))
- local newSpeedX = objectPlayer.Physics.Velocity["x"] + diffToApplyX
- local newSpeedY = objectPlayer.Physics.Velocity["y"] + diffToApplyY
- local newSpeedZ = objectPlayer.Physics.Velocity["z"] + diffToApplyZ
- local play_Val = ba.createVector(newSpeedX,newSpeedY,newSpeedZ)
- objectPlayer.Physics.Velocity = play_Val
- --objectPlayer.Physics.VelocityDesired = play_Val
- --tilt the player model based on the vertical velocity of the ship wrt vertical scrolling.
- if tilt_model == nil then --should only happen once. Get the Subsystem for the "ship" model
- tilt_model = objectPlayer["hull"]
- else
- if tilt_model:isValid() then
- if objectPlayer.Velocity["y"] > (shmup_idle_pscroll_speed["y"] + (shmup_idle_pscroll_speed["y"]*0.05)) then
- tilt_model.Orientation["p"] = tilt_model.Orientation["p"] + (0.05*ft)
- elseif objectPlayer.Velocity["y"] < (shmup_idle_pscroll_speed["y"] - (shmup_idle_pscroll_speed["y"]*0.05)) then
- tilt_model.Orientation["p"] = tilt_model.Orientation["p"] - (0.05*ft)
- else
- --if player is not fast enough, return model to normal position
- end
- else
- ba.error("Tilting model does not exist!")
- end
- end
- end --Player Validity Check
- end
Advertisement
Add Comment
Please, Sign In to add comment