Author Topic: MODULE: Smooth Scrolling & Parallax v1.7.1  (Read 54136 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!
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 won an AGS Award!
    •  
    • Ali worked on a game that was nominated for 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 won an AGS Award!
    •  
    • Ali worked on a game that was nominated for 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
  • Pretty Badass
    • Dualnames worked on a game that won an AGS Award!
    •  
    • Dualnames worked on a game that was nominated for 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 won an AGS Award!
    •  
    • Ali worked on a game that was nominated for 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
  • 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 won an AGS Award!
    •  
    • Ali worked on a game that was nominated for 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 won an AGS Award!
    •  
    • Ali worked on a game that was nominated for 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
  • Pretty Badass
    • Dualnames worked on a game that won an AGS Award!
    •  
    • Dualnames worked on a game that was nominated for 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
  • Pretty Badass
    • Dualnames worked on a game that won an AGS Award!
    •  
    • Dualnames worked on a game that was nominated for 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.

Re: A Smooth Scrolling & Simple Parallax Module (Updated)
« Reply #20 on: 07 Jun 2008, 20:36 »
Hi,
I have imported the module in my game. Then, in the room I want parallax objects, I have put my backgrounds objects, and click on "properties" in the first one.
I have created the property "PxPos - number - default value 0".
Then I choosed for each objects -1, -2 or -3, depending of the distance.
I have add "ParallaxOn()" in the "before fade in" script, and "ParallaxOff()" in the "player leaves room" script.
But when I run the game, I have this error message :



I have 14 objects and they are animated, is that a problem ?

Please help !

Re: A Smooth Scrolling & Simple Parallax Module (Updated)
« Reply #21 on: 09 Jun 2008, 07:55 »
It seems that I have put too many objects in the room. After deleted some of them, it works.

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!
Re: A Smooth Scrolling & Simple Parallax Module (Updated)
« Reply #22 on: 09 Jun 2008, 11:27 »
There is an arbitrary limit of ten parrallax objects. It is possible to increase the number of objects in the module. I think I've added notes along with the scripting. Basically changing the 10s to 15s ought to work.

It's a while since I've had time to work on this module, but I should be able to upload an updated version with a wider variety of object speeds soon. I'll increase the number of objects too.

Re: A Smooth Scrolling & Simple Parallax Module (Updated)
« Reply #23 on: 09 Jun 2008, 11:43 »
That would be great, thank you  :)
But it's ok for me as it is now.
Thank you for this very interesting module !

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!
Re: A Smooth Scrolling & Simple Parallax Module (Updated)
« Reply #24 on: 10 Jun 2008, 09:53 »
See first post for an update.

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.

Thanks for explaining the module to Marion. I don't quite follow this message though. Have you spotted a bug? Could you let me know how you've dealt with it?

I'm sorry but I need help again.
I have begun another game using the scrolling module.
All works well, the effect is great.
But when I leave the room, and re-enter the room, the parallax objects have disappeared ! All the other objects, the ones that don't move, are still there.
I really don't understand why.
I tried using different sizes objects, adding object
  • .SetPosition(x,y) in Before Fade-in script, etc, but nothing, they always disappear when I leave and enter the room the second time.

Please help ! :(

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!
Hi Marion,

I'm sorry, I can't seem to recreate that problem, though I'm sure it'll be something wrong with my scripting.

Does the demo game work correctly when you change rooms (by interacting with the bar door)? If the demo game works, you could try uploading your game files for me to look at if you wanted. Also, which version of AGS are using?

Hi,
the demo game works well.
In fact, I used AGS 2.72 first, but I tried AGS 3 to see if it's ok, but I had the some problems. So I think it's because the template I used. I have made the game again from the beginning with the default template, and now it seems to work.

Well... It still doesn't work :(
I use less objects, I add code "object[].Setposition(x,y)" in Before Fade-In, After fade-in, when using the door, I tried object[].X and object[].Y instead of Setposition, but objects still disappear and are placed anywhere when I change room.
I don't know what to do :(
Can I send you my game in order that you can have a look at it, and see what is wrong ?
Thank you very much. My game will be really less interesting without this scrolling effect. And I wanted it to work for the second part of "Dread Mac Farlane".

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!
Hi,

I've uploaded an update (see first post) which should solve Marion's problem. It seems the old script didn't allow for parallax objects to be created after static objects in the AGS editor. Hopefully that is fixed now.

Let me know if you spot any other issues,

- Ali.

That's great ! I try it, thank you :)

EDIT : It seems to work now ! The objects don't disappear and stay in the same place when I leave and enter the room again. Thank you very much :)
« Last Edit: 14 Jun 2008, 14:30 by Marion »

gypsysnail

  • Snails and cream
    • I can help with animation
    • I can help with backgrounds
    • I can help with characters
    • I can help with proof reading
    • I can help with story design
    • I can help with web design
Hey thats a good module, thanks, have added it to my collection of modules in the hope of using it for one of my games in the near future. I also want to ask (off the topic a bit sorry) - that screenshot at the start of the thread with the crazy? looking doctor and a blue car and golf clubs, what game was that from please? As it looks like a game I'd really like to play.
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

Gilbert

  • Local Moderator
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
You play adventure games and don't know what DOTT was? How can that be?

just kidding. ;D

gypsysnail

  • Snails and cream
    • I can help with animation
    • I can help with backgrounds
    • I can help with characters
    • I can help with proof reading
    • I can help with story design
    • I can help with web design
Lol thanks Gilbot ;). Yep sometimes I'm very bad with remembering names and yep I have heard of that game b4 just not the abbrevation for it. Thanks once again and I will go look at the link you gave me! Excited already!!
Believe in afterlife! It's true in a metamorphical way ;)
Ken & Roberta - my inspiration!! 20 years.
U are what you love doing and passionate about - keep up what you love most.

hedgefield

  • Oh snap!
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
Hey, I've been trying to implement this module in some of my games I'm building with AGS 3.02 SP1, but in some rooms I get this error:



This happens in the first room of my game, which is a scrolling room. But when I start in the second room (also scrolling) - or any other room-, it works perfectly. In another game it also happens in one specific non-scrolling room. What could be the issue here?

1)build .exe
2)run game setup
3)choose graphics driver:direct draw5
4)graphic filter: none
5)run

enjoy.

Pumaman

  • Creator of AGS
  • I sense danger.
    • Lifetime Achievement Award Winner
Hey, I've been trying to implement this module in some of my games I'm building with AGS 3.02 SP1, but in some rooms I get this error:

Did you create the three custom properties (PxPos etc) described at the top of the module script ?

hedgefield

  • Oh snap!
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
choose graphics driver: direct draw5
Yeah thanks those settings have nothing to do with this at all.

Did you create the three custom properties (PxPos etc) described at the top of the module script ?

I have to create those properties anyway even though I don't use parralax objects? It's strange that the scrolling does work if I just start in a different room then. For a next version you might want to specifiy that bit a little more clearly for people who have never used custom properties before.

But anyway that seemed to have been the problem, so thanks. Though now, locking the Viewport doesn't seem to work anymore.
« Last Edit: 15 Sep 2008, 21:20 by largopredator »

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 clearing up that problem CJ, I'm glad it's working for you now largo.

The module header explains that those properties are necessary whether or not you use parallax objects. I thiought it was clear enough, any suggestions for clarification are welcome.

To be honest, I just don't know if it's possible to make the properties optional. Any tips from more experienced scripters would be welcome too.

In the next version, I will warn that the module will override SetViewport. A simple solution would be to temporarily make a dummy character the player, and control camera movement using the dummy in cutscenes etc.

hedgefield

  • Oh snap!
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
I have no idea how it's all coded exactly, but isn't there a way you could toggle the scrolling on/off?

As for the the properties thing, all I can see is //Required Properties:// etc, there's not really a mention of 'you need to go make these custom properties in the custom properties editor of the room'. I happened to remember there was a properties editor there, but I never knew what it was for before.

And the dummy thing might be a good workaround. In another game I already used that method before I figured out the setviewport business.

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!
I have no idea how it's all coded exactly, but isn't there a way you could toggle the scrolling on/off?

I have no idea either... at least I don't have it in front of me so I can't remember. I'll check and let you know if there is. If not, I'll change it for the next version.

Hey

Being using this module wiht AGS 3.1 and in one of the rooms works OK, but when I use it in another room in work OK when player visits room for the first time !!! BUt when I re-enter the room background object dissapears !!!

So I used DISPLAY function to display coordinates of the object, original are 69,206 - but when I reenter the room it changes to 115,445 (thats why object isn't visible)!! I really don't get it !
Game resolution is 800x600.

help

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've notice that the module is appearing all room objects when you re-enter too, but I reset the room after I leave. So all is fine.
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!
Hmm...

Yet again I'm not at my home PC so I can't sort this out immediately. It sounds like the module isn't resetting the objects to their original places for some reason. I thought I'd fixed that problem... but perhaps not! I assume you're using the newer version at the top of this thread.

I'll see if I can recreate your problem and get back to you. For now, you could follow Dualname's suggestion and manually reset the object's position when exiting a room..

I do reset object position after you RE ENTER the room, or EXIT room, but after you re enter the room you can see object for half a second and than it dissapears !? Strange.

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!
largopredator
I've uploaded a new version which allows you to suspend smooth scrolling by setting scrollOn to 0. You would need to use SetViewport to position it wherever suits you, though I think using a dummy character is likely to be more effective.

Sektor 13
I haven't been able to recreate your problem. In the demo game it is possible to exit and return to a room without that problem occuring. Setting the game to 800x600 didn't cause any problems either.

Try using the version I've just uploaded. You shouldn't need to reset the object positions at all, so please remove any code from your room script that does that. The module should record the original positions of the objects and reset them when you leave the room.

If the problem persists once you've got rid of the code affecting object positions, let me know. It might be easiest for you to send me the game in progress, if you'd be happy to do so.

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 do reset object position after you RE ENTER the room, or EXIT room, but after you re enter the room you can see object for half a second and than it dissapears !? Strange.

I get that too. But, I'm using a black GUI which opens at room load and it closes at after fade in so people don't see the object disappearing.
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!
I do reset object position after you RE ENTER the room, or EXIT room, but after you re enter the room you can see object for half a second and than it dissapears !? Strange.

I get that too. But, I'm using a black GUI which opens at room load and it closes at after fade in so people don't see the object disappearing.

I don't get that... are you using fade in / out transitions? Do you set the position of the objects at the start / end of your room script?

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!
When you enter a room that is using the module (yours) objects visible property gets to true. So if you had an object you woudln't want to be show it gets appeared. So I close those objects after fade in(because if i do it on before they will be up), but they get visible for a blip and then disappear. So to solve that I'm opening a black GUI on the room load then fade it on the after room fade in so people don't see the object appear and disappear in a blip.
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!
Ah...  so if I understand you correctly the 'blip' problem arises because the module controls the visibility of parallax objects (this is in order to allow all parallax objects to be hidden on slow computers). I'll try to find a way to allow for this in future, but until now your workaround sounds smart.

Sektor13, If you're seeing blips without manually setting parallax objects' visibility, do let me know. That would mean there's a bigger problem...

EDIT: On second thoughts, Dualnames, why not use a Transparency of 100 set clickable to false on objects you don't want to be visible on entering a room?
« Last Edit: 23 Jan 2009, 11:52 by 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!
Because they get visible on after fade in section from the module,so I have to turn them off after they get.
No more military army stuff. I'm alive and back.

Hmm i have the same problem ! Object just goes away :).


Nickel

  • For a carrot, I'd take you anywhere.
Re: A Smooth Scrolling & Simple Parallax Module
« Reply #52 on: 06 Feb 2009, 23:08 »
Hi everyone!

Thanks for the module, 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.

So something like this will probably not be possible?



Did anyone test it with 800x600 and large objects yet?
What is the D3D version? Of AGS?

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!
Something like that might well be possible with the newer versions of AGS, which support DirectX 9 (which is what I meant by D3D). I've tested it at 800x600 with reasonable large objects, but nothing quite as object-heavy as your example. I suspect that that might work on some computers, but it would definitely slow down on older machines.

Also, the parallax effect doesn't apply to characters, so they'd only be able to walk around the bottom of the screen in your example.

Download the tech demo of Nelly Cootalot II to see parallax at 800x600. A Second Face also uses a bit of parallax at 640x480 (I think). The Jackyard uses very large parallax objects, but it's low res.
« Last Edit: 05 Mar 2009, 13:45 by Ali »

Nickel

  • For a carrot, I'd take you anywhere.
We (Mr Matti and me) just tested it with DirectX 9 and 800x600 pixels and it worked fine on a 2x2 GHz with a bad video card (sis mirage 3)! There is no slowdown.

We used 6 objects with the PxPos -3 to 2 with the factors 1, 0.9375, 0.875, 0.75 and 0.5 in order to have each object scrolling with half the speed of the previous one which creates the effect seen in the picture above.

With every object exept one it works fine, we didn't succeed to get it do what we want and now we are close to getting mad. It seems to be not affected by the lines of code that we think are the right ones...
Honestly we have problems to fully understand that crazy move-with-scrolling-speed-in-opposite-direction-than-scrolling-math-thing.

We uploaded the game folder here. It would be nice if you could take a look at the script and tell us what obvious mistake we made.
« Last Edit: 07 Mar 2009, 19:12 by Nickel »

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!
Hi Nickel,

Sorry I'm not able to check this thread more frequently. I'm glad the effect runs smoothly on your system.

I'm afraid I can't download the file you posted, after waiting 60 seconds it only lets me download a .rar file of 0 bytes. It might be the computer I'm on, but could you try re-uploading it on another site, like filefront?

I've uploaded the data again here and here. I hope one of these will work.

Thanks for having a look.

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!


For a reason in Sierra speech on a scrolling room this happens if the player character walks to a hotspot. To solve it which I have I've put StopScrolling on every of the hotspots. Just saying you might want to put this on the module's readme file.
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!
Nickel & Mr Matti: That looks really cool, and it ran very smoothly for me too. I like the way you've modified the numbers, and there's nothing wrong with the maths. The problem is that objects with PxPos of 0 are ignored by the script and aren't added to the array of parallax objects. It's the default value, so it's needed to create non-parallax which stay in place.

To make it work, use a PxPos of 1 in the script for the segment where you currently use 0, and use 2 where you currently use 1. Changing the corresponding numbers on the nearest two objects made it work properly for me.

Hope that helps!

Dualnames: Thanks for the tip. I always disliked Sierra Speech, but now it's personal.

*Shakes fist at Sierra style dialogue*

I'll add that note the next time I update the module. Thanks!

Thanks Ali, it works perfectly now!
« Last Edit: 23 Mar 2009, 18:45 by Mr Matti »

It seems that one isn't able to manually manipulate the viewport in non-parallax-rooms, even if the parallax effect is turned off - or did I do something wrong? Is there a way you could change that?

Or - even better - to allow the viewport manipulation in parallax-rooms, so that it isn't depending on the player's coordinates?

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 switch the parallax effect on and off, but I haven't created an option to turn smooth scrolling on and off. I may do this when I get the time to update the script.

As a workaround for now, try switching to a dummy character to allow for camera movement.

Let me know if that helps!

The dummy character idea is good, but unfortunately wouldn't work in my case.

Well, I just wait and would be happy if you update your script at some point.

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!
I've added an update, with a cleaned up script. Hopefully you can use the SmoothScroll_StopScroll() function to do what you need.

Let me know if there are any more problems!

hedgefield

  • Oh snap!
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
Link is broken? I get a 0kb file when I download the 1.4 module.

Yeah, me too.

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!
Yeah me too!

I've uploaded the module again and updated the link. It works for me now, and so does the demo.


Did you manage to fix the 'dissapearing-objects'-bug?
It's really strange that in my games some objects have the problem and some don't.

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!
I work on this sporadically with huge breaks in between when real life gets in the way of AGSing.  I accidentally implemented the same function twice at one point, but it's okay now.

I'm afraid I don't remember the details of the bug you mention. An older version required that parallax objects be the first ones created in a room, but that's no longer the case.  Please make sure you have the latest version, and let me know.

With different versions of AGS and different graphical modes there have been issues at the start of rooms where objects jump around. It's hard for me to keep track of this, because of multiple versions of the editor and the fact that it is always being updated. A simple solution to this problem is to use 'Instant Transitions' and a black GUI to create fading effects.

If these don't help, please describe the problem in more detail. Or you could PM me your WIP to see if I can solve the problem.

I used an older version, but I deleted the script and replaced it with 1.4.
But the problem stayed the same. Only the first objects works correctly with the parallax effect. Other objetcs dissapear after re-entering the room.

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 Helme,

The problem was that the module didn't store parallax objects original locations correctly unless they were created before other objects. With luck, version 1.5 should sort this out:

http://www.2dadventure.com/ags/smooth_scroll_module_1.5_b.zip

I'm not sure you're really supposed to get through version numbers this quickly... let me know if the new one works!
« Last Edit: 01 Dec 2009, 21:11 by Ali »

The file has the size of 0 byte - I think it should be bigger  ::)

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!
Sorry, the link was correct on the first post, but not on the one above. I've corrected it now, but I don't know why this keeps happening!

IT WORKS!
Thank you!

AGD2

This is an excellent module. Really impressed with the effects it's capable of creating. :)

In the latest version, however, it seems that Smoothing the motion for distant objects in hi-res might have been broken.

I have a certain distant object (mountains) set up to use View 8, with the object's 4 offset frames assigned to Loop 0.

The effect worked in the previous version of the module, but after upgrading to this new one, the object seems to cycle through all 4 frames, rather than panning smoothly along.

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!
Glad to hear your using the module, but sorry to hear about that problem!

I'm afraid I can't recreate it. I guess this is an effect that looked right before you updated the module?

The smoothing works correctly for me in the demo for resolutions of 640x400 upwards, and with high-res coordinates on and off. Could you give me any more information like the PxPos value of the object, or see if the demo works for you?

AGD2

First I should mention that I previously edited all of the 4.0 values under this section:

Code: [Select]
if (PxObj[objectpass].GetProperty("PxPos")==-1){
... to values of 26.0.  I wanted to have distant mountains scrolling very, very slowly as the character walks.

However, when walking to the LEFT, the codeblock above makes the mountains scroll from right to left. I needed them to scroll left to right instead.  In previous versions of the module, it seemed that if I altered the following lines:

      
Code: [Select]
PxObj[objectpass].X=PxObjOriginX[objectpass]+FloatToInt(IntToFloat(viewx)/4.0);

PxObj[objectpass].Y=PxObjOriginY[objectpass]+FloatToInt(IntToFloat(viewy)/4.0);

..and replaced the instances of + with a -  this would make the mountains scroll the opposite direction instead.  In the latest module version, doing that seems to mess up the smooth scrolling View/Frames, though.

I guess what would be handy, is if you could implement a new PxPos number for distant scrolling objects (like mountains) that scroll left to right, rather than right to left. Either that, or allow the user to somehow specify which direction a distant object should scroll.


Another question:

If I put the following code in the room_Load() function of a screen with parallax scrolling:

function room_Load(){
 player.x=20;
 player.y=327;
 SmoothScroll_PxOn();
}

..if the previous room's background was scrolled to the right, and the player character is then moved into the new room and positioned on the left side, the new room's background will initially be scrolled over the the right too (the inherited position from the previous room). However, after fade-in, the background & parallax objects quickly scroll over to where he's standing on the left.  

What's the best way of ensuring that both the scrolling background and any parallax objects are already set into their correct positions, relative to the player's x/y pos, prior to the screen fading in? So that the player doesn't have to watch them scrolling into position every time a new room loads?


Thanks!
« Last Edit: 06 Dec 2009, 08:31 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!
If I make the changes you describe in function PositionObj(), I get code that looks like this:

Code: [Select]
else if (PxObj[objectpass].GetProperty("PxPos")==-1){
    
PxObj[objectpass].X=PxObjOriginX[objectpass]+FloatToInt(IntToFloat(viewx)/26.0);

PxObj[objectpass].Y=PxObjOriginY[objectpass]+FloatToInt(IntToFloat(viewy)/26.0);
      
if (PxObj[objectpass].GetProperty("PxView")!=0){
      
   fractionx = (IntToFloat(viewx)/26.0)-IntToFloat(FloatToInt(IntToFloat(viewx)/26.0, eRoundDown));
        
   fractiony = (IntToFloat(viewy)/26.0)-IntToFloat(FloatToInt(IntToFloat(viewy)/26.0, eRoundDown));

Here I've replaced 4.0 six times.

When changing these values, it's advisable to make sure the object's initial positions are adjusted accordingly by making this change in function SetOrigins:

Code: [Select]
else if (object[objectpass].GetProperty("PxPos")==1){
        
//Set horizontal origin for object:
PxObjStartX[NumberObj]= object[objectpass].X;
PxObjOriginX[NumberObj] = object[objectpass].X + FloatToInt((IntToFloat(object[objectpass].X)/IntToFloat(Room.Width))*(IntToFloat(Room.Width-System.ViewportWidth)/26.0));
        
//Set vertical origin for object:
PxObjStartY[NumberObj]=object[objectpass].Y;
PxObjOriginY[NumberObj]= object[objectpass].Y + FloatToInt((IntToFloat(object[objectpass].Y)/IntToFloat(Room.Height))*(IntToFloat(Room.Height-System.ViewportHeight)/26.0));
}

Here I've replaced 4.0 twice.

This gives me the effect of an object in the background scrolling very slowly. The smoothing effect works, but is not as pleasing to the eye because of the lack of sub-pixel movement.

I wanted to have distant mountains scrolling very, very slowly as the character walks.

I'm having a little trouble understanding what effect you're tring to achieve, here. A distant object like mountains ought to move more relative to the screen, not less. Changing 4.0 to 26.0 makes my parallax objects appear nearer.

I guess what would be handy, is if you could implement a new PxPos number for distant scrolling objects (like mountains) that scroll left to right, rather than right to left. Either that, or allow the user to somehow specify which direction a distant object should scroll.

If the player walks left, a distant object ought to travel left relative to the screen too. If it travelled in the opposite direction it would appear to be in the foreground. To get that effect you can use positive PxPos values, or have I misunderstood?

If checking over the script doesn't solve the problem, perhaps you could explain the effect you're looking for.

What's the best way of ensuring that both the scrolling background and any parallax objects are already set into their correct positions, relative to the player's x/y pos, prior to the screen fading in? So that the player doesn't have to watch them scrolling into position every time a new room loads?

If for some reason you can't specify the coordinates in the ChangeRoom function in the outgoing room, you could use something like this in the roomLoad function
Code: [Select]
if (player.x!=20 && player.x!=327) player.ChangeRoom (1, 20, 327);
I'll try to make the module support this better in the future, but I can't work it out just now. For the time being, that workaround is your best bet.

I hope that helps!
« Last Edit: 08 Dec 2009, 16:26 by Ali »

AGD2

I edited all the same instances as you, changing 4.0 to 26.0 and achieved the same effect. Changing the pluses to minuses in these lines :

Code: [Select]
PxObj[objectpass].X=PxObjOriginX[objectpass]-FloatToInt(IntToFloat(viewx)/26.0);

PxObj[objectpass].Y=PxObjOriginY[objectpass]-FloatToInt(IntToFloat(viewy)/26.0);

...makes the mountains object scroll the other way, but the frames/sub-pixel movement is jerky, like the frames are displaying in the wrong order. However, if I set the mountain object's PxView Property to 0, it gives me the effect I want (just without using the sub-pixel View/Frames, which, as you mentioned, can't really be noticed at that slow speed anyway).

I know that changing the pluses to minuses isn't really what's intended for negative PxPos values, but it seemed to work before without making the sub-pixel movement jerky, so I just thought I'd mention it, in case something had broken between versions. Either way though, I can still achieve the effect I need.

As for what I'm trying to do. Take a look at this video of the Amiga game Shadow of the Beast and skip to the 2:30 mark:



As the character walks in one direction, the distant mountains appear almost static. But if you look closely,you can see that they're slowly scrolling in the opposite direction than the one the character is walking in.

Granted, the screen I'm working with isn't a direct side-on view like Shadow of the Beast. It has more of an isometric angle with more depth. But due to the diagonal angle the character is moving at, it just looks "right" for the mountains to be traveling away from him, rather than in the same direction.

Quote
I'll try to make the module support this better in the future, but I can't work it out just now. For the time being, that workaround is your best bet.

Sounds good, and thanks for the suggested code. Works a treat! :)

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: [Select]
       if (fractionx<0.5&&fractiony<0.5) PxObj[objectpass].SetView (PxObj[objectpass].GetProperty("PxView"), PxObj[objectpass].GetProperty("PxLoop"), 0); // normal object graphic
        
        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

        else if (fractionx<0.5&&fractiony>=0.5) PxObj[objectpass].SetView (PxObj[objectpass].GetProperty("PxView"), PxObj[objectpass].GetProperty("PxLoop"), 2); //offset 1px downwards

        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: [Select]
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.

is it possible to use this along with the 9-verb MI style template
if so how
sorry for the n00b question
currently on an indefinite hold.

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!
I'm not able to test it right now, but I see no reason why it shouldn't be. It's not 100% compatible with the verb coin template (because the screen scrolls slightly between the time when you click and the time when you choose an action), but there is a workaround for that.

Please try it and let me know if you run into problems!

i will and i will let you know
currently on an indefinite hold.

Hi,

I'm having trouble figuring this out.
I have a very long background and I am using keyboard controls for movement.
Everytime my character gets towards the edge of the screen the screen will scroll but not fast enough.
Eventually the character outruns the screen.

How do I increase the scroll speed of the screen if there are no objects in the room?

Thanks in advance for any help

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!
Try increasing the variable called targetScrollSpeedX and targetScrollSpeedY. You may also need to increase other variables (like slowDownRange) to get it to move smoothly.

Thanks Ali,

That seems to have worked.

I'm having a few troubles now with the character moving a bit choppily.
Is there any way to avoid this?
Also what variable is used to detect how close to the edge the character is?
I would like the edge to be further from the screen so the character doe not have to be close to the edge.

Thanks for the help I really like the look of this module

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!
Hi,

This module doesn't affect character movement. The choppy movement is probably to do with anti-glide mode which is less effective for larger character sprites / walkcycles with more frames.

To change the thresholds look for the comments reading "// Scroll towards the player when they are at the edge of the screen":

For the X Position:

Code: [Select]
        else if (ScrollingAllowedX && PlayerScreenX < (FloatToInt(0.30 * IntToFloat(ScreenWidth))) && PlayerVelocityX <= 0) TargetPointX = player.x; // Scroll towards the player when they are at the edge of the screen
        else if (ScrollingAllowedX && PlayerScreenX > (FloatToInt(0.70 * IntToFloat(ScreenWidth))) && PlayerVelocityX >= 0) TargetPointX = player.x;
        else if (ScrollingAllowedX && PlayerScreenX < (FloatToInt(0.30 * IntToFloat(ScreenWidth))) && PlayerVelocityX > 0) TargetPointX = GetViewportX() + HalfScreenWidth - 6;  //Except if they change direction
        else if (ScrollingAllowedX && PlayerScreenX > (FloatToInt(0.70 * IntToFloat(ScreenWidth))) && PlayerVelocityX < 0) TargetPointX = GetViewportX() + HalfScreenWidth + 6;

And for Y:

Code: [Select]
        else if (ScrollingAllowedY && PlayerScreenY < (FloatToInt(0.30 * IntToFloat(ScreenHeight))) && PlayerVelocityY <= 0) TargetPointY = player.y; // Scroll towards the player when they are at the edge of the screen
        else if (ScrollingAllowedY && PlayerScreenY > (FloatToInt(0.70 * IntToFloat(ScreenHeight))) && PlayerVelocityY >= 0) TargetPointY = player.y;
        else if (ScrollingAllowedY && PlayerScreenY < (FloatToInt(0.30 * IntToFloat(ScreenHeight))) && PlayerVelocityY > 0) TargetPointY = GetViewportY() + HalfScreenHeight - 6;  //Except if they change direction
        else if (ScrollingAllowedY && PlayerScreenY > (FloatToInt(0.70 * IntToFloat(ScreenHeight))) && PlayerVelocityY < 0) TargetPointY = GetViewportY() + HalfScreenHeight + 6;

The '30' and '70' mean that 30% of the screen on the left and right are the scrolling areas. To make the scrolling areas bigger try '40' and '60', to make them smaller try '20' and '80'.

In future releases I will try to make it this simpler to achieve, but I don't have time to work on the module now.

Grim

  • *Dreamer Of The Day*
    • Grim worked on a game that was nominated for an AGS Award!
I've just started using it and I really like it!

I encountered a problem though... If the value of PxPos is below 3 an error comes up and game crashes. It seems that 3 and above displays fine, but it's really moving quite fast... I tweaked targetScrollSpeed because it was too slow and it's now 40... but I don't think that would affect anything, would it?

Also, the game is keyboard controlled in res 800:600.

EDIT: Same for - values.-1, -2 crash the game and -3 makes object practically follow character on the screen like a dog on the leash....
« Last Edit: 20 Jun 2010, 23:06 by Grim »

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!
I've never had a crash like that at 800x600, perhaps it could be caused by keyboard control. Could you post the content of the error message to help me work out what the issue is?

0 is supposed to create static objects for objects a long way off, like the sun in the demo game. The negative numbers are possibly useful for a lens flare effect or similar, but most of the time only 0 and above would be useful. At this time in the morning, I can't think why the crash would happen for values under 3!
« Last Edit: 21 Jun 2010, 08:20 by Ali »

Grim

  • *Dreamer Of The Day*
    • Grim worked on a game that was nominated for an AGS Award!



This came up for an object with PxPos set for 1....

Kweepa

  • Mutated Guano Deviser
    • Best Innovation Award Winner 2009, for his modules and plugins
    • Kweepa worked on a game that was nominated for an AGS Award!
Did you add the PxView property to the schema for objects?
Make sure line 381 still says GetProperty("PxView") - you could have accidentally changed it.
Still waiting for Purity of the Surf II

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 Steve, as far as I can see that must be the problem.

Let me know if you keep having trouble!

Grim

  • *Dreamer Of The Day*
    • Grim worked on a game that was nominated for an AGS Award!
Yeah, line 381 says just that. I haven't altered any of it.

But I think this isn't much of a problem- I'm happy just using setting for 3, 4 and 5. :)

I must also say I really love this module and it really adds a lot to the look of my project already!:) So, thanks!

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!
Glad you're finding it useful. Please let me know if you've added the property PxView? If you haven't then there must be something wrong with the script.

Jonathan Wedge

  • It's the time of ICEY!!!
hey i cant figure out why it gives me an error at 509 & 769. it comes up before the game even starts.

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!
That sounds like you haven't added the required properties. See this section in the module information:

Code: [Select]
////////////////////////
//Required Properties://
////////////////////////
//
// Before starting, you must create the following properties
// in AGS.
//
// NOTE: You must do this even if you do not plan to use
//  the parallax effect. It doesn't take long, but I'm sorry
//  all the same.
//
// PxPos:
//
//  Name: PxPos
//  Description: Stores an object's parallax position
//  Type: Number
//  Default Value: 0
//
// PxView:
//
//  Name: PxView
//  Description: Stores the pixel-adjustment view number
//  Type: Number
//  Default Value: 0
//
// PxLoop:
//
//  Name: PxLoop
//  Description: Stores the pixel-adjustment loop number
//  Type: Number
//  Default Value: 0

Jonathan Wedge

  • It's the time of ICEY!!!
so how do i add'em

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!
Look up the word 'properties' in the AGS manual index. All the information you need is there.

Jonathan Wedge

  • It's the time of ICEY!!!
it works! but is there a way to keep the camera following my player until he stops?

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 mean you want the camera to stop moving the instant the player stops moving, then I'm afraid that's not possible. As it is the player stops, and then the camera takes a short while to come to a stop smoothly.

To make the camera and player stop simultaneously the module would have to anticipate when the player was going to stop and start to slow down. I don't know how I'd script that. Also I think the effect would be unnatural, in film a camera operator rarely stops panning the instant an actor stops moving.
« Last Edit: 07 Sep 2010, 02:08 by Ali »

Jonathan Wedge

  • It's the time of ICEY!!!
If you mean you want the camera to stop moving the instant the player stops moving, then I'm afraid that;s not possible. As it is the player stops, and then the camera takes a short while to come to a stop smoothly.

To make the camera and player stop simultaneously the module would have to anticipate when the player was going to stop and start to slow down. I don't know how I'd script that. Also I think the effect would be unnatural, in film a camera operator rarely stops panning the instant an actor stops moving.
I see,but what i mean i want to have it how it is with this add-on, i want it to be were cego is walking & the camera follows like the module then it keeps follow ego so that he does not go off screen or so he doesn't have to get that close to the wall of the window & so it does not pause even time he get to the spot you click on.

basically when ever i click on an area he move to it and the camera follows then while he is walking i may need hime to go up and not left, the camera the pauses for a sec then starts following again

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!
I can't really understand your writing, is English your first language?

Is the problem is that the camera stops moving when the character is turning? In the demo, Roger will walk down the ladder then turn and cross the screen without the camera stopping completely. Perhaps you could try varying walking speed and scrolling speed so that the camera does not reach the player until he starts moving again. To alter the scrolling speed change the values of targetscrollspeedx and targetscrollspeedy.



Hi

If I want the screen to scroll down as soon as i reach 99 pixels from the upper edge -  where in the script do i change this?


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!
On the off chance you come back to read this month-late response:

I'm afraid the scrolling threshold is set as a percentage of the screen height rather than at a certain pixel.

EDIT This is no longer true. See below:
« Last Edit: 08 Feb 2011, 16:09 by Ali »

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 PM from hedgefield revealed a bug in the Lucas Arts style scrolling. I've updated module and demo on the first post.

The biggest change is int EdgeX and int EdgeY which are the distance from the edge of the screen which the player must be before scrolling happens. Also, the module now scrolls based on the head of a character when moving up, and their feet when moving down.

If you're using the module please update! (And let me know how it's working!)
« Last Edit: 08 Feb 2011, 16:11 by Ali »

hedgefield

  • Oh snap!
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
A-MAZING. Works perfectly now. Thanks for the speedy fix! :D

Maybe I'm just thick but I've never used modules before :P How do I install/use this in my project?

-cheers

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!
Maybe I'm just thick but I've never used modules before :P How do I install/use this in my project?

-cheers

There: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=37884.0
No more military army stuff. I'm alive and back.

ah, I see. Simpler than I thought, thanks!

Edit: NVM, i wasn't thinking properly xD fixed it
« Last Edit: 03 Apr 2011, 12:29 by Blobby 101 »

Hi!
Is there a way to disable the slowdown in scrolling? I want to use this nice module, but only the smooth scrolling part, so I want it to be as the default scrolling, just without the choppiness.
I found a commented line:
if (Centring == false && ScrollSpeedX < 0.5 && ScrollSpeedX > -0.5) ScrollSpeedX = 0.0;
       
This helps a bit, and tinkering with taargetspeed and slowdownrange, I also have results, but there's still some backgroundmovement, after the player stops.
Has anyone else experimented with this? Do you have any "best configuration" results?

Timeless Journey

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!
I'm not sure I understand what you want. How could the movement be smooth without easing in and out?

Incidentally that commented line was designed to get rid of double pixel jumps at the end of a slowdown, but isn't relevant in 3.2 because it moves the screen by single pixels.

I haven't followed this thread recently.. is this still impossible or are you planning to implement it:

to allow the viewport manipulation in parallax-rooms, so that it isn't depending on the player's coordinates?

It would be quite cool for a room in my current game.

I'm not sure I understand what you want. How could the movement be smooth without easing in and out?

Incidentally that commented line was designed to get rid of double pixel jumps at the end of a slowdown, but isn't relevant in 3.2 because it moves the screen by single pixels.

Hmm, you must be right there. Anyway I wanted to minimize the background movement after the player stops.
Thanks for the reply!

Timeless Journey

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!
To do that you can lower the slowdownrange for X and Y. Be sure to test it carefully and choose the right targetscrollspeed, because if the balance is off it will wobble to a stop.

qb

Hi,

any chance of reuploading the module? The links don't work, propably due to inactivity. I can also help with mirroring them if needed.

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!
I've re-uploaded the module and added mirrors thanks to qb. See first post!

This is a great Module, thanks!
"We do not stop playing because we grow old, we grow old because we stop playing."

Joe

  • Anywhere you think I am, I am
    • I can help with scripting
    • I can help with translating
    • I can help with web design
Hey! I really like the smooth scrolling. I'm using it with my game but I'd really like to delete the paralax part. I know I can call the SmoothScroll_PxOn(); function... but I just don't want to have unnecessary code in my game.

Would someone be so kind to make a only-smooth-scrolling module from this one?

Thanks.

Joe
Copinstar © Oficial Site

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!
I'm not able to do it right now, but I'll try to trim that part out when I get a chance. You are right that the bulk of the module is parallax.

UPDATE:
A stripped down version of only-scrolly is here!
http://www.gamefront.com/files/21076580/Smooth+Scrolling+Basic.scm
« Last Edit: 11 Dec 2011, 17:39 by Ali »

Joe

  • Anywhere you think I am, I am
    • I can help with scripting
    • I can help with translating
    • I can help with web design
I get an error on this line:
Code: [Select]
PlayerSprite = Game.GetViewFrame(player.NormalView, player.Loop, 0); // Set it to their current Normal View

I guess it's because it's called when my player isn't using its normal view but other wiew with more loops than the normal view.
I modified that line for this one:

Code: [Select]
PlayerSprite = Game.GetViewFrame(player.View, player.Loop, 0); // Set it to their current Normal View

it works nice now, but I don't know if this is the true solution.
Thanks,
Joe.
Copinstar © Oficial Site

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 not using normal views that seems like a good workaround. To be honest, I can't remember what that bit of code is for, or why I chose to use normal views. Let me know if there are any weird occurrences!

Monsieur OUXX

  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
Hey Ali, have you considered adding the trick of "duplicating the sprites in 2 adjacent positions and blending them together with 50% alpha" to smoothen sub-pixel movement, as was suggested in another thread? That could help for very distant parallax, I guess.
Just an idea.
 

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!
I have thought about it, but I'm not sure how I'd approach it. RawDraw? Or could I create a dynamic sprite and 'map' it to the object? It's not something I'd rule out, but it's not something I could work out quickly.

I'm less keen to achieve sub-pixel movement than I used to be when the engine moved objects in double-pixel jumps. Slow movement looks much better now, particularly at 800x600+ resolution.


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!
Hey, Ali, have you realized that Cinderella's shoe slips off her foot, whilst when she tries them on they're EXACT size? Just an idea.
No more military army stuff. I'm alive and back.

Joe

  • Anywhere you think I am, I am
    • I can help with scripting
    • I can help with translating
    • I can help with web design
If you're not using normal views that seems like a good workaround. To be honest, I can't remember what that bit of code is for, or why I chose to use normal views. Let me know if there are any weird occurrences!

Ok, I will. Anyway I want to thank you for splitting the module. Thankyou very much. :)

Joe
Copinstar © Oficial Site

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 Joe!

Dualnames, once again you have blown my mind.

selmiak

  • ǝsıɔɹǝxǝ ʞɔǝu puɐ uıɐɹq
    • I can help with play testing
    • I can help with proof reading
    • I can help with translating
    • I can help with web design
    • selmiak worked on a game that won an AGS Award!
    •  
    • selmiak worked on a game that was nominated for an AGS Award!
is it possible to set a viewport or a range in which the smoothscrolling should happen? And also have a viewportchange happen with smooth scrolling.
For example you have a very long background but don't want the player to see a specific part of it through scrolling but make it seem like the room ends there. But when the player click on an object at the end of the room the visible screen should move over there as if the playercharacter is looking there. Just looking through moving the part of the background visible for the player and the playercharacter should not move there.

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!
Not without modifying the script a little, but I think it would be possible.

You could create an invisible character called cCamera, and set it to player.x and y. Then replace 'player' with 'cCamera' wherever it appears in the module, so the viewport is following cCamera not the player.

Then make it so that in this particular room cCamera follows the player, but not beyond a certain point. Then when clicking the object, alter cCamera's x value and the viewport should pan over to follow it.

Does that make sense?

selmiak

  • ǝsıɔɹǝxǝ ʞɔǝu puɐ uıɐɹq
    • I can help with play testing
    • I can help with proof reading
    • I can help with translating
    • I can help with web design
    • selmiak worked on a game that won an AGS Award!
    •  
    • selmiak worked on a game that was nominated for an AGS Award!
makes perfect sense, how do I set a characters x+y to players x+y and stop it from moving beyond a certain point? all in global script?
By now I am so far as to have an invisible player character that only walks this and that far and have my normal character walk normally. This works too, but right now I'm at the point where I would have to swap inventory items, so your solution is better, just tell me please how to set this same xy and limit it. But then I would have to have this cCamera in all rooms that are scrolling, right?

Thanks for this great module btw :D
If you find some time, a LockScrollX and LockScrollRangeX parameter would also be cool (same for Y) :D
and a SmoothMoveViewport function maybe ;)

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!
Yes, it would be more flexible if you could swap camera targets in-game, but I won't have time to add that kind of function for a while I'm afraid! It's definitely something I'd like to add.

I haven't tested it, but I'd do something like this (where 1000 is the centre-point you want the screen to stop at):

Code: Adventure Game Studio
  1.  
  2. bool cameraFollowing = true;// Global Variable
  3.  
  4. //In repeatedly execute:
  5.  
  6. if (Player.x < 1000 && cameraFollowing == true){
  7.     cCamera.x = cPlayer.x;
  8.     }
  9. else if (Player.x>=1000 && cameraFollowing == true){
  10.     cCamera.x = 1000;
  11. }

And you could switch the boolean off to manually position cCamera.

I'm not sure if the effect will be perfect with the (relatively) new Lucas Arts style scrolling where scrolling only begins when the player gets near the edge of the screen... so please let me know how it works for you!



« Last Edit: 30 Jul 2012, 02:12 by Ali »

selmiak

  • ǝsıɔɹǝxǝ ʞɔǝu puɐ uıɐɹq
    • I can help with play testing
    • I can help with proof reading
    • I can help with translating
    • I can help with web design
    • selmiak worked on a game that won an AGS Award!
    •  
    • selmiak worked on a game that was nominated for an AGS Award!
It was quite late yesterday, so after posting my last post, shutting down and getting to sleep I figured I could just switch roles and limit my invisible player character and let the dummylookalike move around (make the player the camera) as I already coded some kind of crappy framework for this ;). This works now for me and did cost me some sleep as I was always tempted to reboot and implement this :D

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!
New version for testing: http://ali.agser.me/smooth_scroll_1_7.zip
(Please let me know if you can host a mirror)

This version allows you to change who the camera is looking at with the following code:

Code: Adventure Game Studio
  1. targetCharacter = cDummy;

You could use an invisible character to create camera movements and other effects. The camera has to be pointing at someone at all times. Setting targetCharacter to null should just revert to the player without crashing, but it's better not to try it.

Let me know if you find any bugs!
« Last Edit: 26 Aug 2012, 13:54 by Ali »

New version for testing: http://www.gamefront.com/files/22143642/smooth_scroll_and_parallax_1_7.zip
(Please let me know if you can host a mirror)

This version allows you to change who the camera is looking at with the following code:

Code: Adventure Game Studio
  1. targetCharacter = cDummy;

You could use an invisible character to create camera movements and other effects. The camera has to be pointing at someone at all times. Setting targetCharacter to null should just revert to the player without crashing, but it's better not to try it.

Let me know if you find any bugs!
What happens if you set the targetCharacter to a character not in the current room?
Stuart "Sslaxx" Moore.

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!
It probably crashes. Probably definitely if that character is positioned outside the bounds of the current room.

Thanks for spotting that! I'll try to upload a fix soon.

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!
I've uploaded a fix. In this version the target character should always me moved to the current room to avoid nastiness. Please let me know if you spot any more issues.

It's also now possible to adjust the customScrollSpeedX / Y from other scripts. However, you'll find that very slow speeds don't work, which I'm asking for help about here: http://www.adventuregamestudio.co.uk/forums/index.php?topic=46684.new#new
« Last Edit: 26 Aug 2012, 14:13 by Ali »

Luca

  • 2d is immortal
I just used your module and it's FAN-TAS-TIC!
Thank you!

The baker
Indiana Jones : Archeology = Big Lebowski : Communication Sciences

Ali, can you please remove the restriction that disables smooth scrolling on Linux? I believe current ports should work right.


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!
I have no idea what I meant by emulator either...

I've uploaded a revised version 1.7 with the Linux restriction gone: http://ali.agser.me/smooth_scroll_1_7.zip
« Last Edit: 12 Nov 2013, 15:42 by Ali »

Monsieur OUXX

  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
 
Quote
Sorry for digging up, but I'm having issues for controlling the smooth scrolling, and I thought that the answer could be beneficial to everyone, that's why I'm posting here instead of PM'ing.

First I'd like to say that this module is really sweet. It's a neat effect, and it was made without relying on the Tween module -- that's a cool achievement, technically speaking.

My issue : (I'm detailing steps to reproduce it)
- Create a 320x200 game
- Create a 600x220 room (it's slightly higher than the viewport's height)
- Bring your main character in it, let's say at (50,100).
- Create a dummy character (I'll call it cCamera) which uses a transparent sprite. This one will be used to control the viewport.
- Also bring it into the room, at (1,219). <-- you agree with me that it's at the very bottom of the room.
- In the room script, call

Code: Adventure Game Studio
  1.   SmoothScroll_SetTargetCharacter(cCamera);
  2.   SmoothScroll_ScrollingOn();

What should happen: The viewport should move down and "stick" to the bottom of the room.
What happens: The viewport stays stuck at the top of the room.

I've run tests :
- the issue does not happen when the script moves cCamera left or right: the camera scrolls left and right accordingly.
- I thought it might come from "EdgeY" (defined in the module) so I moved cCamera far down : cCamera.y=400; but it didn't hemp.

What am I doing wrong?


EDIT: this is a tiny bug that Ali explains below. You will experience it only if you make a low-resolution game AND the camera needs to make only a small move (for example, it the room is only slightly larger than the viewport. For example your room is 32x220 and your game is 320x200). It's easily worked around with the solution given by Ali.
« Last Edit: 05 Dec 2014, 13:38 by Monsieur OUXX »
 

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't reproduce that following your instructions and using the version from the first post. The camera scrolls down to the bottom (actually it ends up 1 pixel short of the bottom, to avoid a clunky stop. This is intentional but perhaps not desirable for low-res games.)

The only thing I'm not sure of is why you're using SmoothScroll_SetTargetCharacter(cCamera). Is that your own function? I had to use targetCharacter = cCamera; in its place.

Also, the only reason this doesn't use the Tween Module is that it didn't exist when I started writing it!


Monsieur OUXX

  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
The only thing I'm not sure of is why you're using SmoothScroll_SetTargetCharacter(cCamera). Is that your own function? I had to use targetCharacter = cCamera; in its place.
Silly me, I forgot to mention I added that function. That's the only change I made to the module, it does exactly targetCharacter = cCamera; (I just don't like global variables floating around, that's an OCD thing).
Hmmmm, if you say you can't reproduce it, I'm in trouble. I hope there's no other call to one of your module's functions somewhere else in my gigantic code. I'll investigate more and come back.
« Last Edit: 03 Dec 2014, 15:14 by Monsieur OUXX »
 

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!
Monsieur OUXX has found a bug which affects low res games with rooms only slightly larger than the viewport. Until I update the module, you can fix this problem by changing the 0.7s to 0.3s in whichever of these lines corresponds to the direction in which the screen is reluctant to scroll:

if (Centring == false && ScrollSpeedX < 0.7 && ScrollSpeedX > -0.7) ScrollSpeedX = 0.0;

if (Centring == false && ScrollSpeedY < 0.7 && ScrollSpeedY > -0.7) ScrollSpeedY = 0.0;

Hi guys,

Sorry if this has a very obvious answer or has been addressed before, but I can't find a reference to it. In the game I'm working on, the screen can scroll up and down as well as left and right. Is it possible to fix the Y pos of an object that is being used under PxPOS. I need them to parallax left and right, but not up and down. Does that make sense? Any help much appreciated!

UPDATE: I FOUND THE SOLUTION :D

Shaun
« Last Edit: 09 Dec 2014, 16:44 by shaun9991 »
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

Re: MODULE: Smooth Scrolling & Parallax v1.7.1
« Reply #165 on: 23 Jun 2018, 15:47 »
Hey! I love the smoothscroll + parallax module! It's really awesome!

But I find myself in need of more layers for the background to make things work prettier... Has someone ever added layers ?

I would need something like 25%, 33%, 50%, 66%, 75%, to go from a static (but animated scrolling) sky, to each layer until the front layer...


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!
Re: MODULE: Smooth Scrolling & Parallax v1.7.1
« Reply #166 on: 23 Jun 2018, 16:29 »
I haven't got any plans to add more layers, not least because it would break existing games that use the module. But if you want a more subtle effect, you can play round with the maths in this section:

Code: Adventure Game Studio
  1. if (PxObj[objectpass].GetProperty("PxPos")==7) {
  2.  
  3.       PxObj[objectpass].X=PxObjOriginX[objectpass]-FloatToInt(IntToFloat(viewx)*3.0); //Move the object in opposite direction to the screen scrolling, at 150% of the scrolling speed.
  4.  
  5.       PxObj[objectpass].Y=PxObjOriginY[objectpass]-FloatToInt(IntToFloat(viewy)*3.0);
  6.    
  7.     }

Down to...

Code: Adventure Game Studio
  1. else if (PxObj[objectpass].GetProperty("PxPos")==1) {
  2.      
  3.       PxObj[objectpass].X=PxObjOriginX[objectpass]-FloatToInt(IntToFloat(viewx)/4.0); //Move the object in opposite direction to the screen scrolling, at a quarter of the speed of the scrolling.
  4.  
  5.       PxObj[objectpass].Y=PxObjOriginY[objectpass]-FloatToInt(IntToFloat(viewy)/4.0);
  6.  

So to make them move more subtly, you could change /4.0 to /16.0 for PxPos 1, and so on.

I probably should break those values out into floats, so you can change them from the script. I might do that in a future update, but for now I'm afraid it's up to you to experiment until you get a speed you like.

Re: MODULE: Smooth Scrolling & Parallax v1.7.1
« Reply #167 on: 23 Jun 2018, 17:28 »
the positive 7 to 1 are intended for the foreground object, correct ? I think I found the code for the negatives and made the like:

-1 25% (1.0/4.0)
-2 33% (1.0/3.0)
-3 40% (2.0/5.0)
-4 50% (1.0/2.0)
-5 66% (2.0/3.0)
-6 75% (3.0/4.0)
[nothing]  100%  (is this understanding correct?)
-7 0%

I edited accordingly the code for the positioning too - I replicated the fractions.

I am trying to create more layers in the background (now there are only two -1, and -2), but I am having a hard time making them transit from the foreground layer. Imagine like a tiny plains in the background, to achieve something like the line scrolling Street Fighter 2 uses on the ground, but instead on the distant space...

The idea was to apply in this background example video here . the failed lines.

I can open a topic in the technical forum if it's better.
« Last Edit: 23 Jun 2018, 17:30 by eri0o »

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!
Re: MODULE: Smooth Scrolling & Parallax v1.7.1
« Reply #168 on: 23 Jun 2018, 17:34 »
Sorry, I forgot to mention the positioning! Yes, those are for foreground objects. There's nothing to stop you replacing that whole section with different mutlipliers to create incrementally different parallax layers. I'd be worried about having too many large objects in a room, in terms of performance. But these days, that's much less of an issue.

Re: MODULE: Smooth Scrolling & Parallax v1.7.1
« Reply #169 on: 23 Jun 2018, 18:02 »
Code: Adventure Game Studio
  1.     else if (PxObj[objectpass].GetProperty("PxPos")==-7) {
  2.       PxObj[objectpass].X=PxObjOriginX[objectpass] + viewx; //Keep the object in the same place relative to the screen during scrolling.
  3.       PxObj[objectpass].Y=PxObjOriginY[objectpass] + viewy;
  4.       }
  5.  

Ok, looking through the code, if this is the code to keep the object in the same position, I expect the closer viewx and viewy are from zero, the more anchored is the object to the room bg itself, and so my previous understanding of the fraction was wrong.

Monsieur OUXX

  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
Re: MODULE: Smooth Scrolling & Parallax v1.7.1
« Reply #170 on: 26 Jun 2018, 14:02 »
Coincidence : I also need to post a question about this module right now. Let me know if it interferes with the other conversation.

Spoiler: ShowHide

I'm trying to set up "edges" to the smooth scrolling. What I mean is this : imagine you're in a room that's 600x600. You set up "edges" like this: (Left=100, right = 500, top=100, bottom=500). That's a 400x400 area.
- I want that no matter where the character walks, the viewport never exits that area.
- However when the player character is within that area, then the smooth scrolling follows it normally.

How would I achieve that?

EDIT: I'm in the process of succeeding.
Well I'm not :(
« Last Edit: 26 Jun 2018, 22:36 by Monsieur OUXX »
 

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!
Re: MODULE: Smooth Scrolling & Parallax v1.7.1
« Reply #171 on: 26 Jun 2018, 14:19 »
For the record, eri0o and I moved to DMs, and then he modified the module himself to serve his needs. I didn't abandon him!

To create edges, rather than modify the module, I would have a dummy character pinned to the X and Y of the player as long as they are within the prescribed limits. If they leave the prescribed limits, the dummy stops following and the target character switches to the dummy. Maybe?

Edit: In fact, the target character could always be the dummy, no need to switch.
« Last Edit: 26 Jun 2018, 19:46 by Ali »

Re: MODULE: Smooth Scrolling & Parallax v1.7.1
« Reply #172 on: 26 Jun 2018, 15:20 »
Ali went to pick cigarettes and never returned.

Edit: Ali idea is pretty good, on repeatedly execute always of the room, make a dummy invisible character be at same x & y of player character IF within the bounds, and do nothing if not (this will make the character not move in certain places). Use SmoothScroll's targetCharacter, and do targetCharacter=cDummy.
« Last Edit: 27 Jun 2018, 04:45 by eri0o »

Monsieur OUXX

  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
Re: MODULE: Smooth Scrolling & Parallax v1.7.1
« Reply #173 on: 26 Jun 2018, 22:37 »
I thought I was understanding the script, but I don't. Too many coordinates transformations for my little brain. Anyone could put me in the right direction to add arbitrary edges within the room that lock the scrolling, in replacement of ((0,0), (Room.Width, Room.Height)) ? I don't care if that breaks the parallax, I just need to block the scrolling beyond those edges.

EDIT : I got tired of (failing) to do it elegantly, so instead I went brute force, like this :

Code: Adventure Game Studio
  1.         //COMMENTED OUT
  2.         //SetViewport(FloatToInt(ScreenCentreX, eRoundDown) - HalfScreenWidth, FloatToInt(ScreenCentreY, eRoundDown) - HalfScreenHeight); // Set the Viewport position relative to ScreenCentreX and Y.  
  3.  
  4.         //NEW SCRIPT
  5.         int x = FloatToInt(ScreenCentreX, eRoundDown) - HalfScreenWidth;
  6.         int y = FloatToInt(ScreenCentreY, eRoundDown) - HalfScreenHeight;
  7.        
  8.         if (x<edgeLeft)
  9.             x = edgeLeft;
  10.         else if (x+System.ViewportWidth > edgeRight)
  11.             x = edgeRight-System.ViewportWidth;
  12.        
  13.  
  14.         if (y<edgeTop)
  15.             y = edgeTop;
  16.         else if (y+System.ViewportHeight > edgeBottom)
  17.             y = edgeBottom-System.ViewportHeight;
  18.        
  19.        
  20.         SetViewport(x, y);
  21.  
  22.  
The scrolling doesn't stop as smoothly when the player reachs the edges, but it totally fools the eye for someone who's not seen the original smoothness.
« Last Edit: 26 Jun 2018, 23:02 by Monsieur OUXX »
 

Re: MODULE: Smooth Scrolling & Parallax v1.7.1
« Reply #174 on: 16 Dec 2018, 21:41 »
Hello, My game crashes whenever my character enters idle animation and the game says the problem is in function GetTargetHeight on the line which begins with TargetSprite. Do you have any ideas what could be the problem? EDIT: actually the errors are on lines 521 and 912 and the error says: GetGameParameter: invalid frame specified so i just commented line 912 and 913 but i feel like there should be another way.
« Last Edit: 16 Dec 2018, 21:53 by Hiboy_Luky »

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!
Re: MODULE: Smooth Scrolling & Parallax v1.7.1
« Reply #175 on: 16 Dec 2018, 21:52 »
Does your idle animation have frames in all 4 directions?

Re: MODULE: Smooth Scrolling & Parallax v1.7.1
« Reply #176 on: 16 Dec 2018, 21:54 »
Only in one

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!
Re: MODULE: Smooth Scrolling & Parallax v1.7.1
« Reply #177 on: 16 Dec 2018, 21:58 »
In that case, put the same frame in the other 3 and it should work. (I think you risk AGS crashing anyway, unless the character is permanently locked in one direction.)

Re: MODULE: Smooth Scrolling & Parallax v1.7.1
« Reply #178 on: 16 Dec 2018, 22:01 »
Ok, thanks. I'll try it.