MODULE: Smooth Scrolling & Parallax v1.7.1

Started by Ali, Fri 07/12/2007 21:14:09

Previous topic - Next topic

Ali

For a more up-to-date module, consider downloading Rellax:

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...

Known Issues:

If your character changes view from a tall to a short sprite, the module screen will snap into a new position. This is because it's aiming for the 'head' of the sprite. To get around this, switch targetCharacter to a dummy character (at the same co-ordinates) while you make the transition.

If you're playing as a different character to the player character at game start, and the module has been off, then when you switch it on you the camera will pan from the old character it was following to the current character*. To get around this, set the targetCharacter to the player before calling ChangeRoom, so the camera starts out looking in the right place.

Similarly, if you change a player's X and Y position in room_load, the module will pan from where they used to be to where they are now. If you can, include the desired co-ordinates in the ChangeRoom function. If not, try using a Dummy character who's already in the right place.

*This would be desirable behaviour if you were using it to pan between characters in a cutscene, etc.

subspark

#1
QuoteI 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?

QuoteAlso, 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.

Gilbert

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

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

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

Quote from: subspark on Sat 08/12/2007 04:01:29
QuoteI 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 from: subspark on Sat 08/12/2007 04:01:29
QuoteAlso, 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

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.

joelphilippage

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

#8
Quote from: joelphilippage on Sun 09/12/2007 22:40:43
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.

Dualnames

Wondering Ali, can your module do the kind of magic parallax like in Shadow Of the Beast?
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Ali

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.

joelphilippage

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

Quote from: Ali on Sat 08/12/2007 13:43:56
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

#13
Quote from: joelphilippage on Mon 28/01/2008 03:00:23
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.

Quote from: Snarky on Mon 28/01/2008 09:52:48
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.

subspark

#14
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!

Ali

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.

Marion

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

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.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)


Dualnames

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.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk