Parallax Scrolling

posted in r1ckparker's Journal for project Psy
Published April 04, 2019
Advertisement

I implemented some horizontal scrolling and found that it was not smooth and juddered about, and I realised my timings were out.  I have a viewport on the level and this scrolls to the right.  

The timing of these were not in sync, so I had to re-do the timing.  I don't want to scroll the mid and background every frame, and I can't scroll 1/2 a pixel!   So the solution was to set up a counter.  When counter is 1, scroll the foreground by 1 pixel.  When the counter is 3, scroll the foreground again and also the mid-ground.  When the counter is 5, scroll the foreground, mid ground and background.  Then reset the counter back to 0.  Seems to work well!  Scrolling is nice and smooth.  I also had another issue with 'shimmering' where the pixels did not appear to be smooth as the screen scrolled.  I found this was due to my view port which was scaling the view in my play area.  Fixing this gives me a nice 1:1 pixel ratio and super-smooth parallax scrolling!

There's also a little up-and down scrolling, to make the levels appear a little bigger.  If you are above a certain pixel line, the view scrolls up and if you are below it scrolls down.  It's only a little touch and you probably wouldn't even notice it but it makes the playing area slightly bigger than the view port but not enough that enemies and bullets will be hidden of the top and bottom of the screen.

 

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement