Author Topic: forced scrolling modification  (Read 19859 times)

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
forced scrolling modification
« Reply #30 on: 2005-08-18, 05:59:52 PM »
heh allright! works! now to test the ending sequence.
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
forced scrolling modification
« Reply #31 on: 2005-08-19, 05:16:33 PM »
mmmm seem to be having a little problem with the level.. when i first go into hte level and play normally, it all works fine, it follows the scroller sprite by putting it at the top corner ofhte screen, but when i die and it resets the map, it scrolls at a doubled speed, and since the scroller sprite is a horisontal bar the same width as the screen, the player gets caught on it (due to a collision definition). what i thought it was trying to do was follow that sprite but in the bottom courner of hte screen as opposed to the top. so i removed all the colisions for this and died again, this time it scrolled me right up to the place where i died and stopped. then it wouldnt move at all, even when the "scroller" sprite caught up to it. very strange
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
forced scrolling modification
« Reply #32 on: 2005-08-21, 08:20:38 AM »
1) You shouldn't have a collision definition between the scroller sprite and the player.
2) The sprite doesn't need to be a horizontal bar (it can just be an invisible few pixels)
3) You need to restart the scroller sprite when you die. (This is the real problem).

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
forced scrolling modification
« Reply #33 on: 2005-08-21, 09:26:30 AM »
mmm when the player dies he activates a function that sqitches to teh same map and resets all sprites already
ill post the level later today

-----
k here it is, i deleted as much as possible to make it smaller, its like 5.5mb
http://www.angelfire.com/ct3/billybob884/Chameleon_Man.rar
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
forced scrolling modification
« Reply #34 on: 2005-08-21, 02:42:34 PM »
After Dim ScrollerSprite, add this line:
Code: [Select]
ScrollerSprite = -1
Change this code in OnAfterMoveSprites:
Code: [Select]
  If ScrollerSprite < 0 Then
      ScrollerSprite = FindScrollerSprite
   End If

   If ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer.SpriteCount <= ScrollerSprite Then
      ScrollerSprite = FindScrollerSprite
   End If

   If ScrollerSprite >= 0 Then
      If Left(ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer.Sprite(ScrollerSprite).rDef.Name, 8) <> "Scroller" Then
         ScrollerSprite = FindScrollerSprite
      End If
   End If

   With ProjectObj.GamePlayer
      .MapScrollX = .PlayerSprite.rDef.rLayer.Sprite(ScrollerSprite).X
      .MapScrollY = .PlayerSprite.rDef.rLayer.Sprite(ScrollerSprite).Y

And use an updated version of FindScrollerSprite:
Code: [Select]
Function FindScrollerSprite()
   Dim I
   With ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer
      For I = 0 To .SpriteCount - 1
         If Left(.Sprite(I).rDef.Name, 8) = "Scroller" Then
            FindScrollerSprite = I
            Exit Function
         End If
      Next
   End With
   FindScrollerSprite = -1
End Function

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
forced scrolling modification
« Reply #35 on: 2005-08-21, 07:38:46 PM »
whereabouts in the sub should i put that (the middle quote), maybe over the part that says
   If IsEmpty(ScrollerSprite) Then
      Set ScrollerSprite = FindScrollerSprite
   End If

   If Not ScrollerSprite.rDef.rLayer.pMap Is ProjectObj.GamePlayer.rMap Then
      Set ScrollerSprite = FindScrollerSprite
   End If
?

also, do i need to put "end with" at the end of it?


-----edit-----

and i dont know what those other spam messages are...
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
forced scrolling modification
« Reply #36 on: 2005-08-22, 06:04:14 AM »
Spam messages deleted.

The middle code block should replace the code that looks similar

You're close to correct on which code to replace I think.  But you want to include the subsequent "With" and the first two lines inside the "With" as well.  I think they already look similar to the new code (they start the same way but I changed the end I think).  You already have an end with later on.

-billybob884-

  • Guest
forced scrolling modification
« Reply #37 on: 2005-08-22, 12:34:06 PM »
mm well, im gonna have to pyut that on hold for a day or two, i tried to install a codec pack for a movie i downloaded *watches for the RIAA*, and it changed siomething it shouldnt have, and now i cant open any folders or internet explorer. *sigh* when will i learn?

teh n00b

  • Guest
forced scrolling modification
« Reply #38 on: 2005-08-22, 11:31:41 PM »
u n00b its mpaa...

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
forced scrolling modification
« Reply #39 on: 2005-08-22, 11:38:47 PM »
ok, i put it in like this, it looks right to me (of course thats not saying much),
Code: [Select]
If ProjectObj.GamePlayer.rMap.name = "4-2SpaceFlight" then
oPlayer.ScrollMarginX = 5
oPlayer.ScrollMarginY = 5

   If ScrollerSprite < 0 Then
      ScrollerSprite = FindScrollerSprite
   End If

   If ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer.SpriteCount <= ScrollerSprite Then
      ScrollerSprite = FindScrollerSprite
   End If

   If ScrollerSprite >= 0 Then
      If Left(ProjectObj.GamePlayer.PlayerSprite.rDef.rLayer.Sprite(ScrollerSprite).rDef.Name, 8) <> "Scroller" Then
         ScrollerSprite = FindScrollerSprite
      End If
   End If

   With ProjectObj.GamePlayer
      .MapScrollX = .PlayerSprite.rDef.rLayer.Sprite(ScrollerSprite).X
      .MapScrollY = .PlayerSprite.rDef.rLayer.Sprite(ScrollerSprite).Y
      .MapScrollX = ScrollerSprite.X
      .MapScrollY = ScrollerSprite.Y
      If .PlayerSprite.Y > .MapScrollY + .rMap.ViewHeight - .ScrollMarginY - .PlayerSprite.Height Then
         .PlayerSprite.DY = -.PlayerSprite.rDef.Template.MoveSpeed
      ElseIf .PlayerSprite.Y < .MapScrollY + .ScrollMarginY Then
         .PlayerSprite.DY = .PlayerSprite.rDef.Template.MoveSpeed
      End If

      If .PlayerSprite.X > .MapScrollX + .rMap.ViewWidth - .ScrollMarginX - .PlayerSprite.Width Then
         .PlayerSprite.DX = -.PlayerSprite.rDef.Template.MoveSpeed
      ElseIf .PlayerSprite.X < .MapScrollX + .ScrollMarginX Then
         .PlayerSprite.DX = .PlayerSprite.rDef.Template.MoveSpeed
      End If
   End With

end if


and its telling me Object Required: 'ScrollerSprite' (line 123 character 7)
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
forced scrolling modification
« Reply #40 on: 2005-08-23, 05:40:20 AM »
The lines that start with .MapScrollX and .MapScrollY were supposed to replace the similar two lines that follow.  Delete the 2 shorter lines.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
forced scrolling modification
« Reply #41 on: 2005-08-23, 06:26:01 AM »
I have updated the FAQ to include the new scrolling logic.  Anybody want to double-check / verify my work?
http://sourceforge.net/docman/display_doc.php?docid=26306&group_id=9970

billybob884

  • Contributor
  • Fanatic
  • **
  • Posts: 355
    • AOL Instant Messenger - billybob884
    • View Profile
forced scrolling modification
« Reply #42 on: 2005-08-23, 08:49:40 AM »
ok! verified!  ;)
"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." :: Hitchhiker's Guide to the Galaxy

Bonez

  • Guest
Forced Scrolling?
« Reply #43 on: 2005-08-26, 02:41:17 PM »
I just went over this script and such, I am just curious if any of you could help with a forced screen scroll in the Y direction for a Top down game like spy hunter?

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Forced Scrolling?
« Reply #44 on: 2005-08-26, 03:38:20 PM »
Quote from: "Bonez"
I just went over this script and such, I am just curious if any of you could help with a forced screen scroll in the Y direction for a Top down game like spy hunter?


Why do you need help?  Just use the script described and connect it to a sprite that moves "in the Y direction"... (by naming the sprite "Scroller")