A quick question about parallax effect

Started by Postmodern Adventures, Mon 03/01/2022 19:39:15

Previous topic - Next topic
To make a parallax effect where the foreground object moves faster than the scrolling background, I just had to put this simple line (without the help of modules) in AGS 3.4.3

Code: ags

function repeatedly_execute_always()
{
  ocar1.X=0-(GetViewportX()/2);
}


This works very well. With some "things" that we can talk any other day.

But the GetViewportX  command is now obsolete in 3.5.1

What is the equivalent of GetViewport in 3.5.1? Is it still possible to do a parallax effect with a simple line like the one above?

Crimson Wizard

#1
Strictly speaking it's Game.Camera.X.
If you want to keep using old command, go to General Settings -> Backward Compatibility -> Script compatibility level: set to some level < 3.5.0.

For the futher information:

1. These old commands are still present in the manual, and if you look in their articles, they usually have something like "This function is obsolete since AGS X.X.X, use function N instead".
2. Every time there's a major release there's an article in the manual called "Upgrading to X.X.X". If any commands were changed this is explained there. For example viewport/camera changes are explained in "Upgrading to 3.5.0": https://adventuregamestudio.github.io/ags-manual/UpgradeTo35.html
3. Also now we have a full table of obsolete functions with their replacements for quicker reference:
https://adventuregamestudio.github.io/ags-manual/ObsoleteScriptAPI.html

I'll print that table of obsolete commands and hang it on the wall with a beautiful frame! Thanks CW!

Anyway, since I think parallax is a basic element in any scrolling adventure game ... Have you talked, Ags Wizards, about implementing it from the rooms editor?

Something like this in the object properties:

Parallax : true
Speed: 3


I know it would not be an easy thing and that it would take a lot of work. Or even impossible! I ask it out of curiosity.

Crimson Wizard

#3
Well, there are modules that do that, you have to setup objects in script though.
For instance, this is the recent one: https://www.adventuregamestudio.co.uk/forums/index.php?topic=57489.0



It's of course technically possible to have this in the engine itself, and may be quite easy to do on its own, but one have to come with a good concept of how this suppose to work, because room objects in AGS have multiple functionalities that may contradict parallax effect, so it's important to figure out the design first.

#4
Yes, I'm aware of eri0o and Ali's modules.
And well, that's my Christmas wish for future versions.
Anyway, thanks for your time as always, CW!

Ali

Parallax was only ever a tacked-on feature I added to the smooth scrolling script. I've always felt that both features would be better off built-in to the engine, and I'm sure there are much more efficient ways of scripting it than my attempt. So, for the record, I won't be offended if someone decides to make my module completely redundant (as, I think, other module writers are doing/have done!).

SMF spam blocked by CleanTalk