Will AGS 4 have parallax effects

Started by Joacim Andersson, Thu 02/01/2025 14:00:55

Previous topic - Next topic

Joacim Andersson

Today, you can add several backgrounds to create an animated background, but what about different layered backgrounds to create a parallax effect?

Crimson Wizard

Quote from: Joacim Andersson on Thu 02/01/2025 14:00:55Today, you can add several backgrounds to create an animated background, but what about different layered backgrounds to create a parallax effect?

You can do that with room objects and room overlays.

There are couple of script modules existing which implement this effect:
https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-smooth-scrolling-parallax-v1-7-1/
https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-rellax-0-2-2/

Crimson Wizard

Speaking of having Parallax feature in the engine, first of all we'd need to write down a list of requirements for such feature, in order to make it flexible enough for variety of use cases. It may not be difficult to support multiple background images with automatic offsets, but users may expect more from that.
The first example that comes to mind is animation. We might want to have animated things on parallax layers, in which case they cannot be done just with a single background image. Another idea is a looping layer. There may be something else.

In the meantime, script modules may be a good way to test parallax system interface.

Mehrdad

Is it possible we make a parallax when we have zoom?
My official site: http://www.pershaland.com/

Crimson Wizard

Quote from: Mehrdad on Sat 04/01/2025 14:42:49Is it possible we make a parallax when we have zoom?

Please, elaborate?

Mehrdad

Quote from: Crimson Wizard on Sat 04/01/2025 14:49:53
Quote from: Mehrdad on Sat 04/01/2025 14:42:49Is it possible we make a parallax when we have zoom?

Please, elaborate?

When we zoom in on a scene, the front of the scene moves faster than the back layers (like in a 3D engine like Unity3D). That means we still have parallax.
I know that AGS is a 2D program, but I would really like to know if it is possible to add such a feature.
My official site: http://www.pershaland.com/

Crimson Wizard

#6
Quote from: Mehrdad on Sat 04/01/2025 16:00:52When we zoom in on a scene, the front of the scene moves faster than the back layers (like in a 3D engine like Unity3D). That means we still have parallax.

If I understand correctly, you mean the effect when parallax layers change their relative speed depending on how close or away they become to the "viewer" after we change zoom? I suppose that might be possible to configure too.

Mehrdad

QuoteIf I understand correctly, you mean the effect when parallax layers change their relative speed depending on how close or away they become to the "viewer" after we change zoom? I suppose that might be possible to configure too.

Right. I think it's possible now to change the size of objects and layers when we have zooming.
My official site: http://www.pershaland.com/

Quote from: Joacim Andersson on Thu 02/01/2025 14:00:55Today, you can add several backgrounds to create an animated background, but what about different layered backgrounds to create a parallax effect?

The easiest way to make a parallax effect without modules is this:

Code: ags
 oparallax.X=-(0)-(GetViewportX()/6);

The first number is the position and the next is the speed of the parallax. This is the method I use in my games.

Snarky

Apart from 3D "zoom" (actually "dolly") effects, I would think the slightly tricky part of implementing parallax effects in current AGS is "far distance" background elements that move less than the playable part of the background (let's call that the "mid-ground").

If you want to be able to use hotspots, walkable areas and regions defined in the room editor, you have to put the mid-ground as the background (rather than as an object), but then you can't really put anything behind that.

The only solution I can think of is to put a walkbehind that covers the whole screen except for "holes" where you should be able to see the more distant parallax layers, with a very high baseline so that all normal objects appear in front of it, and only the parallax layers (implemented as objects) appear behind.

And of course, if you want to have playable elements (e.g. hotspots) on these other parallax layers as well, that gets even harder. For example, let's imagine that this is a point-and-click AGS game with parallax:



As you move left and right, the scenery in the background moves more slowly in several parallax layers, and the mountain doesn't move at all. Now if you want e.g. the distant house and the mountain peak to each be a hotspot, how would you do that?

eri0o

When doing this with room objects they may still be clickable.

Joacim Andersson

Quote from: Postmodern Adventures on Mon 06/01/2025 09:19:30The easiest way to make a parallax effect without modules is this:
Code: ags
 oparallax.X=-(0)-(GetViewportX()/6);
I fully understand that you can create parallax effects using different objects today. However, my question was if there were any plans to implement different layered backgrounds (that could have transparency) in AGS 4. What I got from the various replies in this thread is that there currently are no such plans.

Crimson Wizard

#12
Quote from: Joacim Andersson on Mon 06/01/2025 12:29:04I fully understand that you can create parallax effects using different objects today. However, my question was if there were any plans to implement different layered backgrounds (that could have transparency) in AGS 4. What I got from the various replies in this thread is that there currently are no such plans.

Excuse me, but then I did not understand your question correctly. Please tell, what do you imply by "layered backgrounds" precisely?

AGS already sort of can have "layered backgrounds with transparency", which is if you use objects and room overlays.
Did you also mean to have layered masks along with these backgrounds maybe? Or anything else?

@Snarky for complex scenarios, similar to what you describe above, AGS would require to have multiple layers for hotspots, walkable areas etc, where Characters could switch between them.
I recall that tzachs was implementing a similar thing in his MonoAGS, and I even made a tiny demo game in MonoAGS which featured "dolly" + parallax effect. This may be found somewhere in MonoAGS forum thread. If I remember right, walkable areas were just an object, and you could have multiple of them created dynamically (although my memories of MonoAGS are becoming vague today).

Snarky

Quote from: eri0o on Mon 06/01/2025 11:51:34When doing this with room objects they may still be clickable.

If this was in response to me, what I was trying to illustrate with the example image was that you might want a parallax layer where only particular regions would act as hotspots, or you have multiple different hotspots in each layer, etc. You can't easily do that with objects—you'd have to split each layer into separate objects.

Quote from: Crimson Wizard on Mon 06/01/2025 12:36:07@Snarky for complex scenarios, similar to what you describe above, AGS would require to have multiple layers for hotspots, walkable areas etc, where Characters could switch between them.

Yes, that's pretty much what I was getting at.

Crimson Wizard

#14
Quote from: Snarky on Mon 06/01/2025 14:17:31If this was in response to me, what I was trying to illustrate with the example image was that you might want a parallax layer where only particular regions would act as hotspots, or you have multiple different hotspots in each layer, etc. You can't easily do that with objects—you'd have to split each layer into separate objects.

I think the last sentence has a contradiction: yes, you have to split a layer into multiple objects, but no - that still means it is easily done with objects.

Personally I assume that goes without saying: a layer should potentially consist of multiple pieces.

Mehrdad

#15
 I think Tween module can make parallax in zoom in/out too. @edmundito
My official site: http://www.pershaland.com/

Snarky

Quote from: Crimson Wizard on Mon 06/01/2025 14:46:26I think the last sentence has a contradiction: yes, you have to split a layer into multiple objects, but no - that still means it is easily done with objects.

First you have to split them up and create separate sprites. Then you have to align them. And then you have to make sure the different parts move together, potentially scale together (which is a huge hassle in AGS because things can only be positioned on integer coordinates, so you'd have to make each piece the size of the whole canvas with huge transparent regions to avoid misalignment), display in the right z-order, etc. It is not exactly easy IMO.

Joacim Andersson

Quote from: Crimson Wizard on Mon 06/01/2025 12:36:07AGS already sort of can have "layered backgrounds with transparency", which is if you use objects and room overlays.
Did you also mean to have layered masks along with these backgrounds maybe? Or anything else?
That's pretty much what I'm asking for. Today if the background is larger than the viewport, AGS will automatically scroll the background when the player walks around, but I can't have different layers of the background to scroll at different speeds without using overlays or objects, but that doesn't stop the actual background from scrolling, and it requires a lot of extra code. It would be great if you could have 3-5 layers of background images stacked on top and give them some Z layer (even though we're talking 2D games), of course, I understand that then hotspots have to be layered as well.

Since I don't want to use Beta or Alpha versions of the software, I'm not really aware of all the plans you guys have for AGS 4, so that's why I asked.

edmundito

Quote from: Mehrdad on Mon 06/01/2025 14:54:49I think Tween module can make parallax in zoom in/out too. @edmundito

Not exactly. Changing the camera/pos size does not look well at the moment. The problem is documented here:

https://github.com/adventuregamestudio/ags/issues/2612


I'd love to see parallax support configurable in the room settings, but in the meantime, isn't there a parallax module out there?

eri0o

@edmundito I think https://github.com/adventuregamestudio/ags/issues/2427  would need to be done before that one - there may be a mix of having int instead of float for that.

SMF spam blocked by CleanTalk