Author Topic: MODULE: Smooth Scrolling & Parallax v1.7.1  (Read 55897 times)

Ali

  • What will become of the baron?
    • Ali worked on a game that won an AGS Award!
    •  
    • Ali worked on a game that was nominated for an AGS Award!
Hmm... I can create the effect from that video by replacing the 4.0 values with values of 1.5 and without changing the plusses to minuses, and the smoothing effect works correctly. Try that and see if it's preferable.

If you want to stick to your method, then altering the 0, 1, 2, 3 here...

Code: Adventure Game Studio
  1.         if (fractionx<0.5&&fractiony<0.5) PxObj[objectpass].SetView (PxObj[objectpass].GetProperty("PxView"), PxObj[objectpass].GetProperty("PxLoop"), 0); // normal object graphic
  2.        
  3.         else if (fractionx>=0.5&&fractiony<0.5) PxObj[objectpass].SetView (PxObj[objectpass].GetProperty("PxView"), PxObj[objectpass].GetProperty("PxLoop"), 1); //offset 1px to the right
  4.  
  5.         else if (fractionx<0.5&&fractiony>=0.5) PxObj[objectpass].SetView (PxObj[objectpass].GetProperty("PxView"), PxObj[objectpass].GetProperty("PxLoop"), 2); //offset 1px downwards
  6.  
  7.         else if (fractionx>=0.5&&fractiony>=0.5) PxObj[objectpass].SetView (PxObj[objectpass].GetProperty("PxView"), PxObj[objectpass].GetProperty("PxLoop"), 3); //offset 1px to the right and 1px downwards

... to 3, 2, 1, 0 should do it. However the smoothing effect will not be as satisfying because 26.0 results in very small movements.

I can't say why this used to work with earlier versions, but investigating this made me notice that smooth scrolling was broken for objects set to -2! I'll replace the module on the first post.
« Last Edit: 08 Dec 2009, 22:47 by Ali »

AGD2

Sorry about the delay. I just got a chance to test this, and it seems that changing the value to 1.5 is still too fast.

I think the problem is simply a matter of what you mentioned -- the distant objects moving in such small increments that there's no way to avoid it appearing jerky (even with the sub-pixel movement).  Not a problem, though. The parallax effect still looks nice with even just the foreground objects moving. :)

Oh, one other feature that I thought might be useful is the ability to call a function that temporarily 'locks' the screen's viewport and parallax objects into their current positions and allows you to walk around without any screen-scrolling movement or parallax object sliding. This could be useful for cutscenes where you'd like the character to walk around the middle area of a scrollable room, but you don't want the screen/parallax objects to shift by a few pixels and distract the viewer. Of course, it could be turned on/off at will.

Or maybe having some way to specify the x-pos that the player must stand at before the screen begins to scroll left or right. This way the player could cross the halfway point (x-axis) of the screen without having it start immediately shifting. It would allow the player a little buffer zone in the middle of the screen where nothing moves while you walk around in that area.  The point where the shift occurs could be altered from room to room. Don't know if something like that's possible or not?
« Last Edit: 06 Jan 2010, 17:54 by AGD2 »

Ali

  • What will become of the baron?
    • Ali worked on a game that won an AGS Award!
    •  
    • Ali worked on a game that was nominated for an AGS Award!
Thanks for the feedback. You could try smaller values than 1.5, but as you point out very slow movement doesn't look good.

Locking the screen shouldn't be difficult to implement. As a workaround you could try suspending the smooth scrolling effect and calling SetViewport from your script.

Your last idea is something I wanted to implement at the beginning of this module, but couldn't work out how. The classic lucasart games often had smooth scrolling. In those games, the screen didn't start moving until the player was 2/3 of the way across the screen. When I have time to come back to this, I'll see if I can find a way. Making the point at which scrolling starts an alterable value is a good idea too.

Thanks, for the suggestions!

hedgefield

  • Oh snap!
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
I recently programmed the same thing, but in Flash. There, you can query the width of the stage (and divide it by two to get the center). Add (or detract) some value to that, and you essentially have boundaries to trigger the scrolling. Maybe you could try the same thing with the AGS equivalent (System.ViewportWidth)? Or I don't know if you can set room edges via code.

Dualnames

  • Local Moderator
  • Pretty Badass
    • Dualnames worked on a game that won an AGS Award!
    •  
    • Dualnames worked on a game that was nominated for an AGS Award!
Wow, just noticed all those updates! First, a minor thing, but it should be noted somewhere I think, is that if you use SmoothScrolling_Off() we all know all paralax objects get the finger. It's not noted on the header. Thing is if you use SmoothScrolling On, they won't appear. Just bugged me a little and thought it would be best to notify authors that will use it. That's all. It works better than ever though!

No more military army stuff. I'm alive and back.

Ali

  • What will become of the baron?
    • Ali worked on a game that won an AGS Award!
    •  
    • Ali worked on a game that was nominated for an AGS Award!
Thanks largopredator, I'll look into it.

Dualnames, I'm not sure I understand what you mean...

SmoothScroll_ScrollingOff()/SmoothScroll_ScrollingOn() turn the smooth scrolling on and off, but shouldn't affect the parallax objects. SmoothScroll_PxOff()/SmoothScroll_PxOff() turn the parallax objects on and off.

Or is there something I'm missing?

- Ali

Dualnames

  • Local Moderator
  • Pretty Badass
    • Dualnames worked on a game that won an AGS Award!
    •  
    • Dualnames worked on a game that was nominated for an AGS Award!
Thanks largopredator, I'll look into it.

Dualnames, I'm not sure I understand what you mean...

SmoothScroll_ScrollingOff()/SmoothScroll_ScrollingOn() turn the smooth scrolling on and off, but shouldn't affect the parallax objects. SmoothScroll_PxOff()/SmoothScroll_PxOff() turn the parallax objects on and off.

Or is there something I'm missing?

- Ali

Nothing much, I just noticed I did this wrong..(LOL of me), anyway, works like a dream!!!
No more military army stuff. I'm alive and back.

Sorry, wrong thread...

Peter Bear

  • Ph'nglui mglwnafh R'lyeh wgah'nagl Cthulhu fhtagn
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with play testing
    • I can help with story design
    • I can help with translating
    • I can help with voice acting
    • I can help with web design
Hello

Nice Module.

I've just tryied it
But it appears that the room MUST scroll to activate the effect.

I was working on a fixed room, but the foreground is moving, relatively to the character position, so I guess I must seek another module or do something myself.
Not much time for gaming neither creating, but keeping an eye on everything :)

Ali

  • What will become of the baron?
    • Ali worked on a game that won an AGS Award!
    •  
    • Ali worked on a game that was nominated for an AGS Award!
You can't really have a parallax effect without a moving camera... so I guess you're working on something unusual. Let me know what effect you're trying to achieve and I may be able to tell you how to adapt adapt this module.

Also, I'll soon upload an update featuring AGD2's suggestion of a 'dead zone'.

Peter Bear

  • Ph'nglui mglwnafh R'lyeh wgah'nagl Cthulhu fhtagn
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with play testing
    • I can help with story design
    • I can help with translating
    • I can help with voice acting
    • I can help with web design
okay here is a compiled room with the "desired" effect, in the leafs ...

http://www.filefactory.com/file/b0c4dac/n/parallax_hand_made.zip

this is not perfect and I only did a X position changing according to the position of the player character, just like moving in the room should change the point of view "virtually of course" , but maybe am I wrong in my desires lol.
 
manual :
left click : look at ( actually there is no objects in the test room )
right click : move to
escape : game menu ( then press QUITTER to quit ... )
« Last Edit: 21 Mar 2010, 16:11 by Pierceval »
Not much time for gaming neither creating, but keeping an eye on everything :)

Dualnames

  • Local Moderator
  • Pretty Badass
    • Dualnames worked on a game that won an AGS Award!
    •  
    • Dualnames worked on a game that was nominated for an AGS Award!
I can't download it. Have you finished its upload?
No more military army stuff. I'm alive and back.

Peter Bear

  • Ph'nglui mglwnafh R'lyeh wgah'nagl Cthulhu fhtagn
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with play testing
    • I can help with story design
    • I can help with translating
    • I can help with voice acting
    • I can help with web design
well this is another link

http://www.filefactory.com/file/b0c4dac/n/parallax_hand_made.zip

It looks like the host erased my file as soon as it received it.

edit : I must be cursed both hosts refused my file ... is there a AGS GAME filter ?
« Last Edit: 21 Mar 2010, 16:11 by Pierceval »
Not much time for gaming neither creating, but keeping an eye on everything :)

Ali

  • What will become of the baron?
    • Ali worked on a game that won an AGS Award!
    •  
    • Ali worked on a game that was nominated for an AGS Award!
If you're sure you want to do this, I could have a look at the code to see if my module can be used to make it work smoothly.

However there is no reason for the foreground to move if the camera (scrolling) is static. The leaves in the foreground should stay static, and the way they move seems distracting and wrong. Let me know if you're determined to make it work like this and I'll see if my script can help.

Also, have you tried http://www.filefront.com/ ? It's more straightforward than filefactory and has fewer ads.

Peter Bear

  • Ph'nglui mglwnafh R'lyeh wgah'nagl Cthulhu fhtagn
    • I can help with backgrounds
    • I can help with characters
    • I can help with making music
    • I can help with play testing
    • I can help with story design
    • I can help with translating
    • I can help with voice acting
    • I can help with web design
that's okay then I wont scroll them, maybe just animate as the wind could blow throu them

Thank you for your support, I've already downloaded your module so I'll look deep in it, just to ... learn :)

Oh, and for the hosting, I picked the 1st google result on "host files"

Thank you for your time
Not much time for gaming neither creating, but keeping an eye on everything :)

Ali

  • What will become of the baron?
    • Ali worked on a game that won an AGS Award!
    •  
    • Ali worked on a game that was nominated for an AGS Award!
Thanks to the advice given in this thread, I have tweaked the module so that scrolling begins when the player draws near to the edge of the screen. Thanks for the suggestion AGD2!


Please let me know how this version works for you, as I suspect it may need fine tuning depending upon walking speed and so forth:

Module + Demo:
http://www.filefront.com/16047893/smooth_scroll_demo_1.6.zip
Demo game made in 3.1.2 SP1

Module:
http://www.filefront.com/16047885/smooth_scroll_module.zip/

Also, I would be very grateful if someone could host a mirror as these links are non-permanent and 2dadventure has stoped accepting my zip files for some reason.

Dualnames

  • Local Moderator
  • Pretty Badass
    • Dualnames worked on a game that won an AGS Award!
    •  
    • Dualnames worked on a game that was nominated for an AGS Award!
I'll look it up for hosting your files. In the meantime, backing up and updating to 1.6. Two great contributions in one day! :D
No more military army stuff. I'm alive and back.

Ali

  • What will become of the baron?
    • Ali worked on a game that won an AGS Award!
    •  
    • Ali worked on a game that was nominated for an AGS Award!
A note off the back of this thread by Dualnames.

The line below has caused crashes:

Code: Adventure Game Studio
  1. Game.GetViewFrame(player.NormalView, player.Loop, 0); // Set it to their current Normal View

For now you can comment it out without affecting the module. I will remove the line altogether when I upload the next version. At the moment I'd rather wait to hear how the new style scrolling works for people before releasing another version.

AGD2

Looks great, from the demo! Thanks for taking the time to implement this effect. I'll definitely check it out soon, when I get the chance, and give you some feedback.

Dualnames

  • Local Moderator
  • Pretty Badass
    • Dualnames worked on a game that won an AGS Award!
    •  
    • Dualnames worked on a game that was nominated for an AGS Award!
I think the new scrolling effect is definitely impressive. Not that the old one isn't. In fact I like them both. It's up to someone that hasn't seen any of them to comment.
No more military army stuff. I'm alive and back.