• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker 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?
 
S

spoonsinbunnies

Guest
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