Ok, here's what I got so far with the changes you told me to make.
' ======== 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 XOff, YOff
Dim P2OffsetX, P2OffsetY
Dim P2Actions, intSprTwo
Const nSprWidth = 41
Const nSprHeight = 75
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, i
Set oPlayer = ProjectObj.GamePlayer
Set oMap = oPlayer.rMap
Set oLayer = oMap.MapLayer(0)
'Two Player Stuff
'If ProjectObj.GamePlayer.rMap.name = "0-4LevelSelect" or ProjectObj.GamePlayer.rMap.name = "map2" or ProjectObj.GamePlayer.rMap.name = "map3" or ProjectObj.GamePlayer.rMap.name = "map4" then
If ProjectObj.GamePlayer.rMap.name <> "0-4LevelSelect" then
intSprTwo = -1
else
if oLayer.SpriteCount <= 0 Then Exit Sub
If intSprTwo < 0 then
For i = 0 to oLayer.SpriteCount - 1
If oLayer.Sprite(i).rDef.Name = "Player2" then intSprTwo = i
next
End If
With oLayer.Sprite(intSprTwo)
oPlayer.ScrollMarginY = 62
If .ProcessAction(P2Actions) Then
.CurState = (.CurState Mod (.rDef.Template.StateCount \ 2)) _
+ .rDef.Template.StateCount \ 2
.CurFrame = .CurFrame Mod .rDef.StateFrameCount(.CurState)
Else
.CurState = (.CurState Mod (.rDef.Template.StateCount \ 2))
End If
'----------this works great so long as the number of frames in the drifting state is greater than or equal to the number of frames in the accelerating state-------------
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 * 32
nLyrHgt = oLayer.Rows * 32
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 If
'Automatic Scrolling Stuff
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
End if
end if
.rMap.Draw XOff, YOff
End With
End If
End Sub
Sub Player_OnControllerMove(OldActions, NewActions)
'Jumping Player
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
intSprTwo = -1
oPlayer.ScrollMarginY = 185
HostObj.SinkObjectEvents ProjectObj.GamePlayer, "Player"
HostObj.SinkObjectEvents CurrentDisplay, "Display"
HostObj.ConnectEventsNow()