Parallax - Background and Foreground?

Started by EnnarGames, Fri 29/04/2022 02:00:01

Previous topic - Next topic

EnnarGames

Is it possible to create a parallax effect in AGS? If so, how many layers? And even more interesting, is it possible to have foreground and background parallax - similar to some screens in Thimbleweed Park?

Thank you guys!
“Art is an object riddled with sharp edges that can cut you.  You can pound all those edges away and make it smooth and make it safe, but what you’re left with is just a shapeless blob.  It’s safe and it’s smooth, but it’s uninteresting.” Ron Gilbert

Snarky

Quote from: hobbesboi on Fri 29/04/2022 02:00:01
Is it possible to create a parallax effect in AGS?

Yes.

QuoteIf so, how many layers?

This is limited by engine/game performance more than anything. Unless your game is a crazy-high resolution, the answer is probably "enough."

QuoteAnd even more interesting, is it possible to have foreground and background parallax - similar to some screens in Thimbleweed Park?

Yes. Since you're doing it in script, you can make it work however you like.

One limitation is that (unlike Thimbleweed Park) AGS doesn't do sub-pixel positioning, which means that parallax layers that are supposed to move very slowly can appear "jerky."

There are various modules to help without doing parallax. I think the most up-to-date one is https://www.adventuregamestudio.co.uk/forums/index.php?topic=57489.0

Crimson Wizard

#2
Quote from: Snarky on Fri 29/04/2022 05:43:22
One limitation is that (unlike Thimbleweed Park) AGS doesn't do sub-pixel positioning, which means that parallax layers that are supposed to move very slowly can appear "jerky."

Overall a way to improve is to calculate movement (velocity etc) and position in floats, and then convert to pixel pos using "round to nearest" method only when the game object or image itself is repositioned.
This approach helps to create a good enough illusion of smooth movement to human eye.

Also, it's best to do such updates in late_repeatedly_execute_always, as this function is called after game updates itself, but right before it is redrawn.

Snarky

#3
Quote from: Crimson Wizard on Fri 29/04/2022 08:18:41
Quote from: Snarky on Fri 29/04/2022 05:43:22
One limitation is that (unlike Thimbleweed Park) AGS doesn't do sub-pixel positioning, which means that parallax layers that are supposed to move very slowly can appear "jerky."

Overall a way to improve is to calculate movement (velocity etc) and position in floats, and then convert to pixel pos using "round to nearest" method only when the game object or image itself is repositioned.
This approach helps to create a good enough illusion of smooth movement to human eye.

I'm sure the existing modules do this, but still if the update speed falls much below 10 per second at minimum, the human eye no longer sees it as smooth or regular movement, but as "ticks" (move, pause, move, pause, move, pause,…). So something that moves only, say, 2 pixels per second will not seem to be gliding. Check out the moving clouds in this example (which shows a way to implement sub-pixel renderingâ€"or an approximation thereofâ€"in AGS), where one cloud is moving without sub-pixel positioning and two with:

[imgzoom]http://i.imgur.com/K9GoW.gif[/imgzoom]

(A word of caution, though: when the pixels get large, the sub-pixel effect can look a bit weird, sort of like ants crawling across the boundaries. Examine the example above in x8 zoom to see what I mean.)

Crimson Wizard

Hmm, perhaps the similar thing could be emulated using animation frames? For example, have a sprite with transparent parts, object taking roughly 90% of it. First play animation of an anti-aliased movement within the sprite, then move the real object on screen, and repeat starting with animation again.

But I guess drawing over would save some memory at a cost of some cpu load.

Snarky

Yeah, Vince Twelve did that for Resonance, and Ali implemented a version of it in his parallax module. But it adds up quickly, especially if you're doing it in two dimensions (where ten units of sub-pixel accuracy will need 100 copies of each sprite).

I have also been idly thinking about whether it's possible to do something similar for sub-pixel scaling.

SMF spam blocked by CleanTalk