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

Ali

  • What will become of the baron?
    • Ali worked on a game that was nominated for an AGS Award!
      Ali worked on a game that won an AGS Award!
MODULE: Smooth Scrolling & Parallax v1.7.1
« on: 07 Dec 2007, 21:14 »
The Smooth Scrolling & Parallax module is available here:

Version 1.7.1

Download: Smooth Scrolling & Parallax Module

(Please reply or PM me if you can host a mirror)

Module History:

v1.7.1 Fixed bug that disabled parallax when smooth scrolling
       was off.

v1.7 - Added targetCharacter pointer to make camera animation possible without switching player characters. Enabled Smooth Scrolling and Parallax on Linux.

v1.6 - Added LucasArts style scrolling triggered by proximity  to the edge of the screen.

v1.5 - Fixed a major problem with objects not returning to the correct position when leaving and re-entering a room.

v1.4 - Cleaned up script and improved suspension of scrolling effect.
        Added this module history!

v1.3 - Added option to switch smooth scrolling off and on.

v1.2 - A wider range of parallax speeds.
        Less jerky stopping.
        Pixel perfect object movement at slow speeds (not for animated objects, requires a bit of work).
        Up to 25 parallax objects.
        Smooth sun/moon parallax.
        LENS FLARE EFFECT!

v1.1 - Formatted module according to AGS programming conventions.

Notes:

For better lens flares talk to Mr Ryan Timothy...

The module hasn't been tested pre AGS 3.2, but I think it should work. Let me know if it doesn't.
« Last Edit: 18 Jun 2018, 01:08 by Ali »

subspark

  • Some things, you just can't unsee.
    • I can help with animation
    •  
    • 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 proof reading
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: A Smooth Scrolling & Simple Parallax Module
« Reply #1 on: 08 Dec 2007, 04:01 »
Quote
I would also appreciate suggestions on how to create different layers of foreground objects

Do you make your background art in Photoshop? If you do I suggest you work with as many layers as possible and then once your background art is complete collapse as many as you can into groups of background_far, background_close, midground_far, midground_close, foreground.

Note the extreme closup objects like the golf clubs in the following DOTT screenshot:


And the scientific instruments in the foreground of this fate of atlantis screenshot:
(Image removed by mod. since the hosting site is now filed as malicious. It won't show up anyway)

The important thing to remember is to build your background environments from the bottom up. From the background to the foreground and not vice versa.
You need the information behind each layer in order for there be something to look at when the objects move from side to side. So if you start with the background and keep adding onto it with new layers, then keep all your necessary layers in tact then you'll have very little to worry about.
Save each layer out with either an alpha channel or a constant background color. You then recompose your scene layers using your sprites in AGS.

Does this make sense?

Quote
Also, objects in the far distance, like the sun in the demo, look very jerky.
The reason for this is that they are only moving one pixel at a time. This is generally countered by a technique called subpixel movement where the edges of the sprite will blend into the background (antialiasing) to compensate for the movement. Heres an example:

This is what is happening in your scene:
(Image removed by mod. since the hosting site is now filed as malicious. It won't show up anyway)
Your sprites are being shifted as a whole by 1 pixel.

This is what needs to happen in AGS to solve the general jerkyness of sprites:
(Image removed by mod. since the hosting site is now filed as malicious. It won't show up anyway)
The same scene has been rendered with sub pixel smoothing in after effects.

Cheers,
Paul.
« Last Edit: 13 Jun 2018, 16:57 by Gilbert »

Gilbert

  • Local Moderator
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
    •  
Re: A Smooth Scrolling & Simple Parallax Module
« Reply #2 on: 08 Dec 2007, 04:21 »
Please don't post images directly from MobyGames, as they won't show up in a post (unless you had visited the page and had it in your browser cache), I think just posting the link to the page that contains the screenshot may work. As I don't know what page your image's from, I can't fix it for you. Please try to fix it.

subspark

  • Some things, you just can't unsee.
    • I can help with animation
    •  
    • 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 proof reading
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: A Smooth Scrolling & Simple Parallax Module
« Reply #3 on: 08 Dec 2007, 05:06 »
Don't worry Gilbot. I noticed it hadnt worked so I changed it while you were posting. Your message got here first but I didn't notice it until I finished editing my post.

Do you sleep man? You seem to catch me out about 15 seconds after I do something. ;)  It's 4pm here in Australia. Where are you based?

Thanks,
Paul.

Gilbert

  • Local Moderator
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
    •  
Re: A Smooth Scrolling & Simple Parallax Module
« Reply #4 on: 08 Dec 2007, 05:10 »
It's 1:00 pm here, and I'm in the office.

Also, the link doesn't work, as you still link to the image directly. You need to link to the page in MobyGames that contain the image to work.

Ali

  • What will become of the baron?
    • Ali worked on a game that was nominated for an AGS Award!
      Ali worked on a game that won an AGS Award!
Re: A Smooth Scrolling & Simple Parallax Module
« Reply #5 on: 08 Dec 2007, 13:43 »
Quote
I would also appreciate suggestions on how to create different layers of foreground objects

Do you make your background art in Photoshop? If you do I suggest you work with as many layers as possible and then once your background art is complete collapse

Thanks, but I didn't make myself clear. By different layers of foreground objects I meant altering the code to make foreground object move at different speeds relative to the screen. I haven't been able to get anything like that working.

Quote
Also, objects in the far distance, like the sun in the demo, look very jerky.
The reason for this is that they are only moving one pixel at a time. This is generally countered by a technique called subpixel movement where the edges of the sprite will blend into the background (antialiasing) to compensate for the movement.

Subpixel movement isn't supported at the moment, as far as I know. I was looking for a practical way of diminishing the jerkiness by allowing the movement to slow down smoothly but stop before the jerkiness becomes too noticeable.

Also for low-res games the sun still appears jerky, but I think the rest of the movement should look fine.

subspark

  • Some things, you just can't unsee.
    • I can help with animation
    •  
    • 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 proof reading
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: A Smooth Scrolling & Simple Parallax Module
« Reply #6 on: 09 Dec 2007, 01:42 »
Fair enough. Actually your idea of stopping the movement before it moves 1 pixel further is a good idea.
Good luck with this Ali.

Cheers,
Paul.

Re: A Smooth Scrolling & Simple Parallax Module
« Reply #7 on: 09 Dec 2007, 22:40 »
I was trying this out with Lif and when I leave the first room and come back, the object in the foreground moves from where I originally placed it, over to the place were it should be where the camera is. Also the camera corrects it's self after the room loads. I hope I made the problem clear.



Ali

  • What will become of the baron?
    • Ali worked on a game that was nominated for an AGS Award!
      Ali worked on a game that won an AGS Award!
Re: A Smooth Scrolling & Simple Parallax Module
« Reply #8 on: 10 Dec 2007, 11:11 »
I was trying this out with Lif and when I leave the first room and come back, the object in the foreground moves from where I originally placed it, over to the place were it should be where the camera is. Also the camera corrects it's self after the room loads. I hope I made the problem clear.

Thanks for that, it drew my attention to a number of problems. This version should solve that problem, as well as giving you the option to switch the parallax objects off to improve performance:

Edit: Dead link.
« Last Edit: 13 Jun 2018, 12:27 by Ali »

Dualnames

  • Local Moderator
  • Rottwheelers
  • Pretty Badass
    • Dualnames worked on a game that was nominated for an AGS Award!
      Dualnames worked on a game that won an AGS Award!
Re: A Smooth Scrolling & Simple Parallax Module
« Reply #9 on: 13 Dec 2007, 10:05 »
Wondering Ali, can your module do the kind of magic parallax like in Shadow Of the Beast?
No more military army stuff. I'm alive and back.

Ali

  • What will become of the baron?
    • Ali worked on a game that was nominated for an AGS Award!
      Ali worked on a game that won an AGS Award!
Re: A Smooth Scrolling & Simple Parallax Module
« Reply #10 on: 13 Dec 2007, 12:51 »
I'm afraid this module is pretty simple and just moves objects around. To create parralax with large background images would require very big objects, which might be too much for the AGS engine.

On the other hand, I haven't tested the D3D version much, so larger objects may prove to be less of a barrier in the future.

Re: A Smooth Scrolling & Simple Parallax Module
« Reply #11 on: 28 Jan 2008, 03:00 »
I was testing my game that uses this module and I found a problem. The screen is only 400 pixels tall so it does not scroll up but it still moves the objects up which looks pretty weird. Can you fix it so that the objects do not move up and down if the screen does not?
Thanks.



Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: A Smooth Scrolling & Simple Parallax Module
« Reply #12 on: 28 Jan 2008, 09:52 »
Subpixel movement isn't supported at the moment, as far as I know. I was looking for a practical way of diminishing the jerkiness by allowing the movement to slow down smoothly but stop before the jerkiness becomes too noticeable.

Also for low-res games the sun still appears jerky, but I think the rest of the movement should look fine.

I was just thinking about this, and I think you could manually render a few subpixel displacements (in an external image editing app), and then switch out the graphics as appropriate. Of course, you'll multiply the size taken up by the graphics by however many steps you want in the subpixel movement, but if you're only using it for a few objects that are gonna move slowly it might be OK.

Ali

  • What will become of the baron?
    • Ali worked on a game that was nominated for an AGS Award!
      Ali worked on a game that won an AGS Award!
Re: A Smooth Scrolling & Simple Parallax Module
« Reply #13 on: 28 Jan 2008, 11:19 »
I was testing my game that uses this module and I found a problem. The screen is only 400 pixels tall so it does not scroll up but it still moves the objects up which looks pretty weird. Can you fix it so that the objects do not move up and down if the screen does not?
Thanks.

Hi JPP,
That definitely isn't right. I forgot about 640x400 resolution when I put the module together. I'm not at home so I can't give you an update now. If you want to attempt it yourself, I suspect the solution will be to change values that read '240' (half of 480) to '200' (half of 400). I'll try and sort this out soon though.

I was just thinking about this, and I think you could manually render a few subpixel displacements (in an external image editing app), and then switch out the graphics as appropriate. Of course, you'll multiply the size taken up by the graphics by however many steps you want in the subpixel movement, but if you're only using it for a few objects that are gonna move slowly it might be OK.

That is a good idea, thanks.

Update:

The module link on the first post should solve your resolution based problems Joel.
« Last Edit: 29 Jan 2008, 13:51 by Ali »

subspark

  • Some things, you just can't unsee.
    • I can help with animation
    •  
    • 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 proof reading
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: A Smooth Scrolling & Simple Parallax Module (Updated)
« Reply #14 on: 03 Mar 2008, 09:52 »
Thats exactly what I had in mind Snarky. I probably should have been more elaborate with the explaination of my concept.
Hows the parallax module going anyhow, Ali? Still tinkering?  ;)

Cheers,
Paul.

Edit: Ali seems to have incorperated subpixel movement into the module already! Congrats to us both Snarks! And big applause for Ali!
« Last Edit: 15 Jan 2010, 15:01 by subspark »

Ali

  • What will become of the baron?
    • Ali worked on a game that was nominated for an AGS Award!
      Ali worked on a game that won an AGS Award!
Re: A Smooth Scrolling & Simple Parallax Module (Updated)
« Reply #15 on: 06 Mar 2008, 10:43 »
Hello,

Not much progress as yet, and I haven't yet worked out how to implement Snarky's suggestion, particularly allowing for sprite numbers to vary from game to game. I'll post an update as soon as I have something worth playing with.

I have discovered that this module requires an adjustment of the verb-coin module for them to function correctly together. I'll post an ammended version next time I'm able to update this.

-Ali.
« Last Edit: 06 Mar 2008, 10:50 by Ali »

Re: A Smooth Scrolling & Simple Parallax Module (Updated)
« Reply #16 on: 03 Jun 2008, 09:14 »
Hi,
I'm not very familiar with modules. How exactly can I use the scroll module ? I have imported it in the game, but what are the codes to use it in the script ?
Thank you very much.

Dualnames

  • Local Moderator
  • Rottwheelers
  • Pretty Badass
    • Dualnames worked on a game that was nominated for an AGS Award!
      Dualnames worked on a game that won an AGS Award!
Re: A Smooth Scrolling & Simple Parallax Module (Updated)
« Reply #17 on: 03 Jun 2008, 21:21 »
Well, it's easy to use. You create a number of properties(one per parallax object)
Anyway, then you select an object at a room and select properties pages and add a value at one property(it doesn;t matter and you don;t need to change all properties hey'll change all).The value can take 3-1 foreground -1/-2/-3 background.
Add before fade in the line
ParallaxOn()
and room leave
ParallaxOff().


Ali: It's a cool module. Planning on making HHGTG using a lot of it. Thanks a lot, mate.
No more military army stuff. I'm alive and back.

Re: A Smooth Scrolling & Simple Parallax Module (Updated)
« Reply #18 on: 04 Jun 2008, 06:43 »
Thank you for your answer. I will try.

Dualnames

  • Local Moderator
  • Rottwheelers
  • Pretty Badass
    • Dualnames worked on a game that was nominated for an AGS Award!
      Dualnames worked on a game that won an AGS Award!
Re: A Smooth Scrolling & Simple Parallax Module (Updated)
« Reply #19 on: 04 Jun 2008, 08:30 »
Whilst i was using the module I had this object with Px property value of -2. So I wanted this object to be interactable. StopScrolling didn;t use and parallax off closed all objects with px value. So I've created a small code that can be used..in order to walk near an object. Parallax is still on whilst you walk.
No more military army stuff. I'm alive and back.