Hey, I was wondering if anyone would be able to tell me how to put these 2 pieces of script together so they'd be able to work at the same time.
This first part is the 'forced scrolling' script (for my flying level) with a 'jump button' script form the script generator combined. This bit is being used with my game right now:
Option Explicit
Dim XOff, YOff
Sub Player_OnAfterMoveSprites()
If ProjectObj.GamePlayer.rMap.name = "2-4BonusLevel" then
XOff = XOff + 1
With ProjectObj.GamePlayer
if .PlayerSprite.X <= XOff then
if .PlayerSprite.DX < 0 then .PlayerSprite.DX = 1
.PlayerSprite.DX = .PlayerSprite.rDef.Template.MoveSpeed
if .PlayerSprite.X < XOff - .PlayerSprite.Width / 2 then
XOff = 1
.bQuit = false
End if
end if
.rMap.Draw XOff, YOff
End With
End If
End Sub
Sub Player_OnControllerMove(OldActions, NewActions)
With ProjectObj.GamePlayer.PlayerSprite
If (Not OldActions) And NewActions And ACTION_BUTTON2 Then
If (.rDef.SolidTest(.X, .Y + .Height) Or .rDef.SolidTest(.X + .Width - 1, .Y + .Height)) Or (Not .pRideOnRef Is Nothing) Then
.DY = - .rDef.Template.JumpHeight
End If
End If
End With
End Sub
HostObj.SinkObjectEvents ProjectObj.GamePlayer, "Player"
HostObj.ConnectEventsNow()
ProjectObj.GamePlayer.Play 16
This next part is the 'split screen' script, it's for the part of my game that's 2 player:
NOTE: I'm going to need this to be in effect for 3 or 4 separate 2 player maps, so I don't know if that can be put into one line like in the 'forced scroll' part, or if the whole 'split screen' part will need to be copied over each time per map.)
' ======== INITIAL STARTUP SCRIPT (Number 0) =========
Sub Player_OnPlayInit()
HostObj.StartScript=1
End Sub
HostObj.SinkObjectEvents ProjectObj.GamePlayer, "Player"
HostObj.ConnectEventsNow()
ProjectObj.GamePlayer.Play 16
Option Explicit
Dim P2OffsetX, P2OffsetY
Dim P2Actions
Const nSprWidth = 32 ' Could be retrieved, but would be slower
Const nSprHeight = 32
Sub Display_KeyDown(KeyCode, Shift)
' E=69, S=83, D=68, F=70
If KeyCode = 69 Then P2Actions = P2Actions Or ACTION_UP
If KeyCode = 83 Then P2Actions = P2Actions Or ACTION_LEFT
If KeyCode = 68 Then P2Actions = P2Actions Or ACTION_DOWN
If KeyCode = 70 Then P2Actions = P2Actions Or ACTION_RIGHT
End Sub
Sub Display_KeyUp(KeyCode, Shift)
If KeyCode = 69 Then P2Actions = P2Actions And Not ACTION_UP
If KeyCode = 83 Then P2Actions = P2Actions And Not ACTION_LEFT
If KeyCode = 68 Then P2Actions = P2Actions And Not ACTION_DOWN
If KeyCode = 70 Then P2Actions = P2Actions And Not ACTION_RIGHT
End Sub
Sub Player_OnAfterMoveSprites()
Dim oMap, oPlayer, oLayer, nLyrWid, nLyrHgt
Set oPlayer = ProjectObj.GamePlayer
Set oMap = oPlayer.rMap
Set oLayer = oMap.MapLayer(0)
With oLayer.Sprite(1)
.ProcessAction(P2Actions)
oMap.ViewTop = 240
If P2OffsetX + oPlayer.ScrollMarginX > .X Then
P2OffsetX = .X - oPlayer.ScrollMarginX
End If
If P2OffsetX + oMap.ViewWidth - oPlayer.ScrollMarginX < .X + nSprWidth Then
P2OffsetX = .X - oMap.ViewWidth + oPlayer.ScrollMarginX + nSprWidth
End If
If P2OffsetY + oPlayer.ScrollMarginY > .Y Then
P2OffsetY = .Y - oPlayer.ScrollMarginY
End If
If P2OffsetY + oMap.ViewHeight - oPlayer.ScrollMarginY < .Y + nSprHeight Then
P2OffsetY = .Y - oMap.ViewHeight + oPlayer.ScrollMarginY + nSprHeight
End If
If P2OffsetX < 0 Then P2OffsetX = 0
If P2OffsetY < 0 Then P2OffsetY = 0
nLyrWid = oLayer.Columns * nSprWidth
nLyrHgt = oLayer.Rows * nSprHeight
If P2OffsetX > nLyrWid - oMap.ViewWidth Then P2OffsetX = nLyrWid - oMap.ViewWidth
If P2OffsetY > nLyrHgt - oMap.ViewHeight Then P2OffsetY = nLyrHgt - oMap.ViewHeight
oMap.Draw P2OffsetX, P2OffsetY, False
oMap.ViewTop = 0
End With
End Sub
HostObj.SinkObjectEvents ProjectObj.GamePlayer, "Player"
HostObj.SinkObjectEvents CurrentDisplay, "Display"
HostObj.ConnectEventsNow()
My deepest thanks to who ever can figure this out :? .