Glitchy Scrolling

Started by subspark, Tue 08/05/2007 05:15:45

Previous topic - Next topic

subspark

Dear AGSers',

Have you ever noticed that scrolling scenes are very jerky?
It seems the scrolling is based on character position rather than where the mouse clicked.

While this may be a good thing, is there some way, CJ, to average out the scroll speed when a character moves through a scrolling scene?

Up until now scrolling has always looked awkward.



Cheers,
PW.

Gilbert

For more "under-controlled" scrolling, you can always programme it by modifying the Viewport sontinuously in the game.

subspark

I would think this is something that everybody could benefit from. I would suggest its more of an engine update rather than a per user workaround. Smooth scrolling is not inconceivable, however, it does present itself as something that should be done accross the board.

Is this reasonable, CJ?

Cheers,
PW.

scotch

Sounds like you have anti glide mode turned on?
When it's enabled, the character only moves when the character's walking frame changes, which helps prevent any sliding about of your character's feet (as long as you made the animation consistent with the movement speed). It's often desirable... but if your animation doesn't have many frames, or you're using high resolution, and you're using the default scrolling, then it can create a noticably choppy scroll. You have a couple of options... 1: add more frames to your walk animation (ideally have 0 delay on the frames, but this is a lot of work). 2: turn off anti glide mode (but this could look a little slippery... up to you to decide). 3: decouple the scrolling from the character, instead of being locked to center on the character position, change it so that it smoothly scrolls to the character.

I don't think any of these options should be part of the engine, because the way it is now is the way most people would want it, I think.

In a hi res or otherwise modern style game I'd do number 3. It's very easy to do, just put the appropriate code in repeatedly execute. And it can be tweaked any way you like.

Fee

Maybe hes using the zoom feature. I notice that on larger scrolling rooms with the zoom at around 70% the scrolling gets a littel jerky. Experimenting a little with the animation speed and character speed helps a little.

Ali

Quote from: subspark on Tue 08/05/2007 06:37:51
Smooth scrolling is not inconceivable, however, it does present itself as something that should be done accross the board.

I would like smooth scrolling to be in-built, but until then you could play with the code Steve McCrea posted on this thread:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=25937.0

It has the viewport ease in and out of a character's position. It needs a little tweaking, but you can see it in action in Nelly Cootalot (below). That game doesn't actually use anti-glide mode, but I guess this would provide smoothness either way.

subspark

Thats the kind of thing. I second that!

Pumaman

scotch has explained the reason why this happens; since everyone would have their own interpretation of how "smooth scrolling" should work, I think this is best left to the script & script modules.

subspark

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=25937.0

A great find but an example demo would be more usefull. Steve's just given us the core. The rest is missing for less seasoned programmers like myself.

Cheers,
Paul.

Ali

Steve's made it clear that he doesn't have the time to turn that code into a module, what with all his other wheelings and dealings, and I don't have the time or scripting confidence to put one together.

You're right that it's not complete. That script doesn't scroll to a smooth stop when the viewport reaches the end of the screen. It also causes problems with verbcoins (screen-relative co-ordinates), and with scrolling finishing before dialogue options appear.

I'm very busy at the moment, but if I find a moment I'll upload the code I used in Nelly Cootalot where I've sorted those problems. If you can't wait, I suggest you experiment with that script yourself. I'm not a seasoned programmer, but I managed to cobble together something effective.

subspark

#10
Well if your not a seasoned programmer, then I am a first-time tinkerer. Theres no way for me to get a working module without months of training and thats not exactly my department.
I'm quite a patient man and I would be most appreciative of any time you can spare on this when you get the chance.

Cheers mate,
Paul W.

Ali

#11
Here's the code I have in repeatedly_execute_always
Code: ags

//Ease in/out scrolling
if (System.OperatingSystem != eOSLinux){
	float targetScrollSpeed = 22.0; // pixels per second
	float slowDownRange = 70.0; // pixels

	SetViewport(FloatToInt(screenCentre, eRoundNearest) - 160, 0);
	
	if (cN.x<160) scrollOffset = 160.00 - screenCentre;
	else if ((Room.Width - cN.x)<160) scrollOffset = IntToFloat(Room.Width-160) - screenCentre;
	else scrollOffset = IntToFloat(cN.x) - screenCentre;
	
	
	if (scrollOffset > -slowDownRange && scrollOffset < slowDownRange)
	{
		 targetScrollSpeed = (scrollOffset/slowDownRange)*targetScrollSpeed;
	}
	else
	if (scrollOffset < 0.0) 
	{
		targetScrollSpeed = -1.0*targetScrollSpeed;
	}
	float timeStep = 10.0/40.0;
	scrollSpeed += timeStep*(targetScrollSpeed - scrollSpeed);
	screenCentre += (timeStep*scrollSpeed);
}
// Scrolling finished


Bear in mind the following things:

cN would obviously need to be replaced with cEgo or whatever you use.

Some of the values would have to be changed at 800x600.

You can tweak the top two values to tailor the movement.

If you use the standard dialogue interface you need to add a line of script to each talk-to-character interaction. I'm not on my home computer and I forgot to bring that line with me. Basically it needs to make the game wait while scrollOffset is greater than 0 (using FloatToInt). Otherwise the dialogue options pop up before the screen stops scrolling.

EDIT: This is the line I used to make the gain wait for the screen to stop scrolling:
Code: ags
while (FloatToInt(scrollOffset, eRoundNearest)!=0) Wait (1);


Also if you use a click-and-hold verbcoin, you may need to adjust the script because the screen coordinates will change in relation to the room coordinates in the time between the player's click and the verbcoin appearing.

I hope that helps!

EDIT: I forgot to say. Of course you have to declare these variables:
Code: ags
float scrollSpeed = 0.0;
float screenCentre = 0.0;
float scrollOffset= 0.0;




SMF spam blocked by CleanTalk