'Flickering' character sprite when following on a scrolling room w/ SetViewport

Started by Lewis, Tue 28/04/2020 11:29:29

Previous topic - Next topic

Lewis

Right. So for a particular scene I need the camera to follow a 'character' (a moving vehicle) in the centre of a vertically scrolling screen. Easy enough.

Problem is, the vehicle sprite includes an effect coming out of the back of the vehicle - with the vehicle itself in the top half of the sprite and the trail effect a the bottom. Because the vehicle itself is at the top of the sprite, the screen isn't scrolling until the top of the vehicle nears the top of the screen, so it's continually off-centre vertically as it scrolls.

I figured I could resolve this by manually offsetting the viewport in repeatedly_execute_always, but there's a problem - the sprite now 'flickers' up and down by a few pixels with each game loop. I assume this is because the rep_ex is checking precisely one frame offset against the movement of the sprite.

The most annoying thing is that I know I've solved this problem before, many moons ago. But I've searched and searched and experimented and experimented and can't figure it out.

Here's the rep_ex_always code that results in the flicker effect:

Code: ags
SetViewport(cBuggy.x, cBuggy.y-400);


Any help very much appreciated!
Returning to AGS after a hiatus. Co-director of Richard & Alice and The Charnel House Trilogy.


Lewis

Returning to AGS after a hiatus. Co-director of Richard & Alice and The Charnel House Trilogy.

SMF spam blocked by CleanTalk