MODULE: Smooth Scrolling & Parallax v1.7.1

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

Previous topic - Next topic

Ali

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

The Smooth Scrolling & Parallax module is available here:

Version 1.7.1

Download: Smooth Scrolling & Parallax Module

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

Module History:

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

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

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

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

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

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

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

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

Notes:

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

Known Issues:

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

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

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

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

subspark

#1
QuoteI would also appreciate suggestions on how to create different layers of foreground objects

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

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


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

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

Does this make sense?

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

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

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

Cheers,
Paul.

Gilbert

Please don't post images directly from MobyGames, as they won't show up in a post (unless you had visited the page and had it in your browser cache), I think just posting the link to the page that contains the screenshot may work. As I don't know what page your image's from, I can't fix it for you. Please try to fix it.

subspark

Don't worry Gilbot. I noticed it hadnt worked so I changed it while you were posting. Your message got here first but I didn't notice it until I finished editing my post.

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

Thanks,
Paul.

Gilbert

It's 1:00 pm here, and I'm in the office.

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

Ali

Quote from: subspark on Sat 08/12/2007 04:01:29
QuoteI would also appreciate suggestions on how to create different layers of foreground objects

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

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

Quote from: subspark on Sat 08/12/2007 04:01:29
QuoteAlso, objects in the far distance, like the sun in the demo, look very jerky.
The reason for this is that they are only moving one pixel at a time. This is generally countered by a technique called subpixel movement where the edges of the sprite will blend into the background (antialiasing) to compensate for the movement.

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

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

subspark

Fair enough. Actually your idea of stopping the movement before it moves 1 pixel further is a good idea.
Good luck with this Ali.

Cheers,
Paul.

joelphilippage

I was trying this out with Lif and when I leave the first room and come back, the object in the foreground moves from where I originally placed it, over to the place were it should be where the camera is. Also the camera corrects it's self after the room loads. I hope I made the problem clear.



Ali

#8
Quote from: joelphilippage on Sun 09/12/2007 22:40:43
I was trying this out with Lif and when I leave the first room and come back, the object in the foreground moves from where I originally placed it, over to the place were it should be where the camera is. Also the camera corrects it's self after the room loads. I hope I made the problem clear.

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

Edit: Dead link.

Dualnames

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

Ali

I'm afraid this module is pretty simple and just moves objects around. To create parralax with large background images would require very big objects, which might be too much for the AGS engine.

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

joelphilippage

I was testing my game that uses this module and I found a problem. The screen is only 400 pixels tall so it does not scroll up but it still moves the objects up which looks pretty weird. Can you fix it so that the objects do not move up and down if the screen does not?
Thanks.



Snarky

Quote from: Ali on Sat 08/12/2007 13:43:56
Subpixel movement isn't supported at the moment, as far as I know. I was looking for a practical way of diminishing the jerkiness by allowing the movement to slow down smoothly but stop before the jerkiness becomes too noticeable.

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

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

Ali

#13
Quote from: joelphilippage on Mon 28/01/2008 03:00:23
I was testing my game that uses this module and I found a problem. The screen is only 400 pixels tall so it does not scroll up but it still moves the objects up which looks pretty weird. Can you fix it so that the objects do not move up and down if the screen does not?
Thanks.

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

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

That is a good idea, thanks.

Update:

The module link on the first post should solve your resolution based problems Joel.

subspark

#14
Thats exactly what I had in mind Snarky. I probably should have been more elaborate with the explaination of my concept.
Hows the parallax module going anyhow, Ali? Still tinkering?  ;)

Cheers,
Paul.

Edit: Ali seems to have incorperated subpixel movement into the module already! Congrats to us both Snarks! And big applause for Ali!

Ali

Hello,

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

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

-Ali.

Marion

Hi,
I'm not very familiar with modules. How exactly can I use the scroll module ? I have imported it in the game, but what are the codes to use it in the script ?
Thank you very much.

Dualnames

Well, it's easy to use. You create a number of properties(one per parallax object)
Anyway, then you select an object at a room and select properties pages and add a value at one property(it doesn;t matter and you don;t need to change all properties hey'll change all).The value can take 3-1 foreground -1/-2/-3 background.
Add before fade in the line
ParallaxOn()
and room leave
ParallaxOff().


Ali: It's a cool module. Planning on making HHGTG using a lot of it. Thanks a lot, mate.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)


Dualnames

Whilst i was using the module I had this object with Px property value of -2. So I wanted this object to be interactable. StopScrolling didn;t use and parallax off closed all objects with px value. So I've created a small code that can be used..in order to walk near an object. Parallax is still on whilst you walk.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Marion

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 !

Marion

It seems that I have put too many objects in the room. After deleted some of them, it works.

Ali

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.

Marion

That would be great, thank you  :)
But it's ok for me as it is now.
Thank you for this very interesting module !

Ali

See first post for an update.

Quote from: Dualnames on Wed 04/06/2008 08:30:36
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?

Marion

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

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?

Marion

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.

Marion

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

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.

Marion

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 :)

gypsysnail

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

You play adventure games and don't know what DOTT was? How can that be?

just kidding. ;D

gypsysnail

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

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?

Mehrdad

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

enjoy.
My official site: http://www.pershaland.com/

Pumaman

Quote from: largopredator on Mon 15/09/2008 11:38:58
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

Quote from: MEHRDAD on Mon 15/09/2008 16:29:43
choose graphics driver: direct draw5
Yeah thanks those settings have nothing to do with this at all.

Quote from: Pumaman on Mon 15/09/2008 20:24:55
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.

Ali

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

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

Quote from: largopredator on Tue 16/09/2008 14:33:01
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.

Sektor 13

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

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

Ali

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

Sektor 13

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

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

Quote from: Sektor 13 on Mon 19/01/2009 14:10:41
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.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Ali

Quote from: Dualnames on Tue 20/01/2009 09:04:46
Quote from: Sektor 13 on Mon 19/01/2009 14:10:41
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

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

Ali

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?

Dualnames

Because they get visible on after fade in section from the module,so I have to turn them off after they get.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Sektor 13

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


Nickel

Hi everyone!

Thanks for the module, Ali.

Quote from: Ali on Thu 13/12/2007 12:51:56
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

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.

Nickel

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.

Ali

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?

Matti

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

Thanks for having a look.

Dualnames



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

Ali

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!

Matti

Thanks Ali, it works perfectly now!

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

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!

Matti

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

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

Link is broken? I get a 0kb file when I download the 1.4 module.


Ali

Yeah me too!

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


Helme

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

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.

Helme

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

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!

Helme

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

Ali

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!

Helme


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

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: ags
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: ags
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!

Ali

If I make the changes you describe in function PositionObj(), I get code that looks like this:

Code: ags
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: ags

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.

Quote from: AGD2 on Sun 06/12/2009 08:25:07
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.

Quote from: AGD2 on Sun 06/12/2009 08:25:07
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.

Quote from: AGD2 on Sun 06/12/2009 08:25:07
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: ags
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!

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: ags

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:

http://www.youtube.com/watch?v=WnHY7qUPPro

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.

QuoteI'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

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

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?

Ali

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

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

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!

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Ali

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

Quote from: Ali on Sat 16/01/2010 00:05:54
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!!!
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)


Peter Bear

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

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

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 ... )
Not much time for gaming neither creating, but keeping an eye on everything :)

Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Peter Bear

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 ?
Not much time for gaming neither creating, but keeping an eye on everything :)

Ali

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

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

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

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

Ali

A note off the back of this thread by Dualnames.

The line below has caused crashes:

Code: ags
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

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

Jackpumpkinhead

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

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!

Jackpumpkinhead

currently on an indefinite hold.

snaggletooth

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

Try increasing the variable called targetScrollSpeedX and targetScrollSpeedY. You may also need to increase other variables (like slowDownRange) to get it to move smoothly.

snaggletooth

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

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: ags
        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: ags
        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

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

Ali

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!

Grim


Kweepa

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

Thanks Steve, as far as I can see that must be the problem.

Let me know if you keep having trouble!

Grim

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

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.

Icey

hey i cant figure out why it gives me an error at 509 & 769. it comes up before the game even starts.

Ali

That sounds like you haven't added the required properties. See this section in the module information:

Code: ags

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

Icey


Ali

Look up the word 'properties' in the AGS manual index. All the information you need is there.

Icey

it works! but is there a way to keep the camera following my player until he stops?

Ali

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.

Icey

Quote from: Ali on Tue 07/09/2010 01:42:46
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

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.


Icey


mr_cool

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

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:

Ali

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

hedgefield

A-MAZING. Works perfectly now. Thanks for the speedy fix! :D

Blobby 101

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

-cheers

DOWNLOAD

Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Blobby 101

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

Edit: NVM, i wasn't thinking properly xD fixed it

DOWNLOAD

bbalint85

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

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.

Matti

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

Quote from: Matti on Fri 13/11/2009 18:51:39
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.

bbalint85

Quote from: Ali on Fri 13/05/2011 14:32:58
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

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

I've re-uploaded the module and added mirrors thanks to qb. See first post!

LostTrainDude

"We do not stop playing because we grow old, we grow old because we stop playing."

Joe

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

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

Joe

I get an error on this line:
Code: ags

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: ags

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

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

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

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

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

Joe

Quote from: Ali on Mon 12/12/2011 17:50:48
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

Thanks Joe!

Dualnames, once again you have blown my mind.

selmiak

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

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

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

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: AGS


bool cameraFollowing = true;// Global Variable

//In repeatedly execute:

if (Player.x < 1000 && cameraFollowing == true){
    cCamera.x = cPlayer.x;
    }
else if (Player.x>=1000 && cameraFollowing == true){
    cCamera.x = 1000;
}


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!




selmiak

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

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: AGS
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!

Sslaxx

Quote from: Ali on Fri 17/08/2012 22:01:44
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: AGS
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

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

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

Luca

I just used your module and it's FAN-TAS-TIC!
Thank you!

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

Crimson Wizard

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


Ali

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

Monsieur OUXX

#160
 
QuoteSorry 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: ags
  SmoothScroll_SetTargetCharacter(cCamera);
  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.
 

Ali

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

#162
Quote from: Ali on Wed 03/12/2014 09:38:37
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.
 

Ali

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;

shaun9991

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
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

eri0o

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

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: ags
if (PxObj[objectpass].GetProperty("PxPos")==7) {

      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.

      PxObj[objectpass].Y=PxObjOriginY[objectpass]-FloatToInt(IntToFloat(viewy)*3.0); 
    
    }


Down to...

Code: ags
else if (PxObj[objectpass].GetProperty("PxPos")==1) {
      
      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.

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


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.

eri0o

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

Ali

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.

eri0o

Code: ags

    else if (PxObj[objectpass].GetProperty("PxPos")==-7) {
      PxObj[objectpass].X=PxObjOriginX[objectpass] + viewx; //Keep the object in the same place relative to the screen during scrolling.
      PxObj[objectpass].Y=PxObjOriginY[objectpass] + viewy;
      }


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

#170
Coincidence : I also need to post a question about this module right now. Let me know if it interferes with the other conversation.

Spoiler

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?
[close]
EDIT: I'm in the process of succeeding.
Well I'm not :(
 

Ali

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

eri0o

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

Monsieur OUXX

#173
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: ags

        //COMMENTED OUT
        //SetViewport(FloatToInt(ScreenCentreX, eRoundDown) - HalfScreenWidth, FloatToInt(ScreenCentreY, eRoundDown) - HalfScreenHeight); // Set the Viewport position relative to ScreenCentreX and Y.  

        //NEW SCRIPT
        int x = FloatToInt(ScreenCentreX, eRoundDown) - HalfScreenWidth;
        int y = FloatToInt(ScreenCentreY, eRoundDown) - HalfScreenHeight;
        
        if (x<edgeLeft)
            x = edgeLeft;
        else if (x+System.ViewportWidth > edgeRight)
            x = edgeRight-System.ViewportWidth;
        

        if (y<edgeTop)
            y = edgeTop;
        else if (y+System.ViewportHeight > edgeBottom)
            y = edgeBottom-System.ViewportHeight;
        
        
        SetViewport(x, y);


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.
 

Hiboy_Luky

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

Ali

Does your idle animation have frames in all 4 directions?


Ali

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


vga256

Hi Ali! I'm porting (Chicky's) Guard Duty to Linux and Mac, and I noticed that I cannot seem to get targetCharacter to work in Linux. The exact same code works fine in Mac and Windows, but for some reason Linux seems to be completely ignoring targetCharacter? I've included some videos to document the behaviour -- I was hoping you might be able to point me in the right direction!

The Linux and Mac ports are using v3.4.15 of the AGS interpreter. In Linux we're using Allegro 4.4.3 - the latest version of Allegro (just released a month ago), and an OpenGL renderer. Morganw also tested this out with the Software renderer, just in case OpenGL was causing the problem, and the same problem occurred with software rendering as well.

Some sample videos of what we're seeing:
Expected behaviour (Mac OS X): Camera pans down to knight when mouse hovers at bottom of screen.
Unexpected behaviour (Linux/Ubuntu): Mouse hovers at bottom of screen, and camera does not pan.
Another sample from a different part of the room:
Expected behaviour (Mac OS X): Camera pans down to knight, and you can use the ladder on the knight.
Unexpected behaviour (Linux/Ubuntu): Mouse hovers at the hotspot, but the camera doesn't pan to the knight.

Are there Linux-specific settings that need to be used, or have we missed something coding the scene to make it work in Linux? Chicky's project is using v1.7 of the module.

Thanks so much.

Crimson Wizard

Quote from: vga256 on Sun 24/03/2019 17:25:50
Hi Ali! I'm porting (Chicky's) Guard Duty to Linux and Mac, and I noticed that I cannot seem to get targetCharacter to work in Linux. The exact same code works fine in Mac and Windows, but for some reason Linux seems to be completely ignoring targetCharacter?

Curiously, we have reported Linux-related bug many years ago: https://www.adventuregamestudio.co.uk/forums/index.php?topic=33142.msg636472912#msg636472912
but it was supposed to be fixed.

Try searching for "eOSLinux" in the script.

On the other hand, this may be a new engine's bug too.


Ali

Yes, originally the module would cause a fatal crash on Linux, so it was disabled by default. But, as you can see, that line is now commented out. Frankly I have no idea what the problem is. The module doesn't do anything fancy in terms of scrolling. It just decides where to setviewport based on the co-ordinates of a particular character. So I can't see why that wouldn't work on Linux.

I'm afraid I don't have a Linux OS here to test it on. But I would try to narrow down the cause of the problem. Does setting *targetCharacter in the script succeed (i.e. the pointer is changed to cCharacter2, but the screen doesn't move)? Or does it fail for some reason and the pointer stays set to cCharacter1?

For instance, if you modify game_start in the module to:

Code: ags
function game_start(){
  if (cEgo.Room == TEST ROOM)  targetCharacter = cCharacter2;
  else targetCharacter = player;
  
  system.vsync=true;
}
(Pseudocode)


And run the room, does it follow the other character instead?

vga256

#182
Pretty embarrassing that I didn't catch the     if (System.OperatingSystem != eOSLinux) line in the script XD
This must have been an old script that somehow didn't get updated to the commented version? I don't know how it happened, but nonetheless .. it's now commented out :D

Thank you - I've commented out the line and its matching closing brace, and will recompile with both. I'll update this thread when I see the outcome.

vga256

Recompiled and it's running perfectly in Linux now. Thanks again! :D

Monsieur OUXX

 

Blondbraid

Does anyone know how to install this module on the 3.5 AGS engine? The new changes have me a bit confused.


Ali

Sorry, I haven't used 3.5 at all yet. Maybe try Rellax, which seems more up to date?

Crimson Wizard

Quote from: Blondbraid on Wed 27/05/2020 15:06:17
Does anyone know how to install this module on the 3.5 AGS engine? The new changes have me a bit confused.

In General Settings set "Script compatibility level" to 3.4.1.

Blondbraid

Quote from: Ali on Wed 27/05/2020 15:18:55
Sorry, I haven't used 3.5 at all yet. Maybe try Rellax, which seems more up to date?
Well, I wanted to use this module as I'm working on a MAGS project and wanted to have something I was familiar with when working on a time limit, but I might try it out on my next project. Still, it would be interesting to see what you could do with this module for the latest version if you find the time for it.
Quote from: Crimson Wizard on Wed 27/05/2020 16:25:03
Quote from: Blondbraid on Wed 27/05/2020 15:06:17
Does anyone know how to install this module on the 3.5 AGS engine? The new changes have me a bit confused.

In General Settings set "Script compatibility level" to 3.4.1.
Thanks, I tried that and it seems to work!


Laura Hunt

Hi Ali, I'm having a bit of a problem with this module. Is it ok to post here (might be helpful in case anybody else has the same issue?), or should I PM you?

Ali

Yes, you can post it here for exactly that reason. The module is a little out-of-date now, but I'll help if I can.

Laura Hunt

Thank you!

The issue I'm having is that I want to activate smooth scrolling for only one room, but when I put SmoothScroll_ScrollingOn(); in my room_Load(), the viewport gets stuck to the top left corner and doesn't move from there.

My game's resolution is 320x200, and this room is 480x300. I'm using AGS 3.4.3 P1.

In case it helps shed some light, previous to this I have called SmoothScroll_ScrollingOff(); in game_start because I wanted to use the parallax effect for the main menu but not the smooth scroll functionality, because I'm scrolling the viewport with tweens instead.

Thanks again!

Ali

Is the target character (by default, the player character) in the room? If they are, then I'm not sure. If you want, you could PM me the room and I could have a look. You could also check whether the newer module Rellax works for you: https://www.adventuregamestudio.co.uk/forums/index.php?topic=57489.0

Laura Hunt

Well, that's interesting. The player character is indeed in the room, but for some reason it's not being set as the target character. I explicitely set targetCharacter = cTestCharacter; and everything works as it should, with one exception: the viewport "snaps" into place vertically after the room fades in. I thought the character might be too close to the edges, but it's happening regardless of where I start him off. Have you ever had this happen before?

Laura Hunt

#194
Managed to fix it, although I have no idea what's going on.

If I use cTestCharacter.SetAsPlayer() in the previous room, I get this weird viewport "snap" after the next room loads. But if I do player.ChangeRoom(51, 348, 217, eDirectionLeft) instead, then everything works fine.

In any case, I definitely need to explicitely set targetCharacter = player. For some reason, the module is not doing it automatically.

In any case, I managed to get it running, so thanks a lot for your help! :)

Ali

I'm not sure why that's happening, but I'm glad you've found a workaround! Sorry I haven't been able to keep this up-to-date.

Ali

#196
Based on Laura's issue, I'm going to add a couple of known issues which are work-aroundable.

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

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

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

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

Laura Hunt

#197
Edit: Ali and I posted at exactly the same time, but his explanation is so much better than mine, so I'm editing mine out so as not to add any confusion :)

Thanks again Ali for going above and beyond the call of duty!

rongel

I had similar problems with Smoothscroll that were connected to changing the player character. I didn't understand what was going on, but simpy using the targetCharacter  = player again seems to have fixed the situation. Feels good that I can remove my own messy fixes!

Thanks Ali, Laura and Crimson Wizard!
Dreams in the Witch House on Steam & GOG

my2k

sorry for some thread necromancy....

so I don't know if this has been addressed, this is as close as I've seen, but:
when I'm moving and the screen is smooth-scrolling, if I click on a character and dialogue begins, the dialogue scrolls along with the room- not the gui, not anything else, JUST the drawn "character.SayAt(etc);" type dialogue. I'm trying to figure out how I can have the dialogue stay along with the GUI, where the view below the dialogue box keeps moving but the dialogue box itself doesn't. I can't set GUIs' PxPos as 0, so it's not possible to keep it stationary.

if I use
  cEgo.StopMoving();
  SmoothScroll_StopScroll();

it'll have the screen slow to a stop- which is great anywhere else- but it unfortunately is a bit lengthy when waiting for dialogue to display. Ideally it'd slow to a stop as normal but that dialogue wouldn't move.

Do we know why JUST the dialogue seems to keep moving with the scrolling screen but the GUI doesn't? how can I keep that dialogue stop moving?
 

Quote from: Ali on Tue 17/03/2009 09:56:30
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!

Crimson Wizard

#200
Quote from: my2k on Tue 16/03/2021 05:55:28
so I don't know if this has been addressed, this is as close as I've seen, but:
when I'm moving and the screen is smooth-scrolling, if I click on a character and dialogue begins, the dialogue scrolls along with the room- not the gui, not anything else, JUST the drawn "character.SayAt(etc);" type dialogue.

Please tell which speech style you are using (and which version of AGS)? For instance, afaik Lucas Arts speech style locks to particular room position to be above character, so when the camera moves it will move along the room background.

EDIT:
But I don't remember if same happens with SayAt.
I also don't think this is supposed to happen with Sierra style speech. Only have vague memories hearing about some issue years ago.

Ali

I've never used Sierra style speech, and frankly I don't know how to set it up (the Sierra template in AGS 2.5 seems to use LucasArts style speech and switching on SierraWithBackground doesn't seem to do anything...). So I haven't managed to test the dialogue and GUI going out of alignment with each other.

However, I'm not sure the module has control over this issue. SayAt uses screen, rather than room co-ordinates. But (as CW says) AGS pins the text to the background, so if the viewport scrolls the text moves along with it. Presumably because it would usually be attached to a speaker. As far as I know, a module can't make SayAt behave differently.

SMF spam blocked by CleanTalk