GMS 2 Background following Viewport

Here we go again :D

I am creating a parallax background for my game, and I know how to make the background follow the player around. The background jumps around with oPlayer, which of course looks unrealistic.

The code I am currently using to position my background sprites (code in oBackground that I drop into my room):
layer_x("Backgrounds_2", oPlayer.x / -1.5);
layer_x("Backgrounds_3", oPlayer.x / -3);
layer_x("Backgrounds_4", oPlayer.x / -6);
layer_x("Backgrounds_5", oPlayer.x / -9);

layer_y("Backgrounds_2", oPlayer.y-160);
layer_y("Backgrounds_3", oPlayer.y-160);
layer_y("Backgrounds_4", oPlayer.y-160);
layer_y("Backgrounds_5", oPlayer.y-160);

Very basic.

Is it possible to stretch a background to fit the viewport and follow the viewport when moving the player object around in GMS2?
 
I believe 6:36 is the explanation of what your looking for using lerp to make the background percentage based around your view, unless your asking if we can stretch a smaller than view background in which case I'm not necessarily sure how to accomplish that for you
 
Top