Scrolling Game Development Kit Forum
SGDK Version 1 => Script => Topic started by: sam on 2006-04-02, 04:29:24 PM
-
Okay, this is going to be hard to explain. If you've ever played Donkey Kong Country 3 before, than you might notice when you run to the edge of the screen and then quickly run back to the other edge of the screen the scrolling speed slows down and allows the player to get a bit further away from the middle of the screen before the scrolling cathches up with the player.
-
For something like that, I'd probably change the scroll margins. Specifically, ProjectObj.GamePlayer.PlayerSprite.ScrollMarginX, and (possibly) ProjectObj.GamePlayer.PlayerSprite.ScrollMarginY.
Maybe have some code that lets the game know when you've turned around, change the scroll margin, and then set a timer so you know when to change it back? I'll let someone else handle specifics, though, since I've never played the game. But if you can handle some scripting, you might be able to do it yourself...
-
Set your scroll margins to a low number like 32, then try adding script like this to Player_OnAfterScrollSprites:
With ProjectObj.GamePlayer
DiffX = .PlayerSprite.X - .MapScrollX - 304
DiffY = .PlayerSprite.Y - .MapScrollY - 224
If Abs(DiffX) > 5 Then XSV = XSV + Log(Abs(DiffX)) * SGN(DiffX) / 5
If Abs(DiffY) > 5 Then YSV = YSV + Log(Abs(DiffY)) * SGN(DiffY) / 5
.MapScrollX = .MapScrollX + XSV
.MapScrollY = .MapScrollY + YSV
XSV = XSV * .95
YSV = YSV * .95
If ABS(XSV) < 1 Then XSV = 0
If ABS(YSV) < 1 Then YSV = 0
End With
And add the variable declarations to the top of the script:
Dim XSV, YSV
It's not perfect, but I think it's getting close to what you want.
-
Holy, thanks a lot. :)
Looks so sweet!