Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

Scrolling Backgrounds Game Maker


Mr.S

Recommended Posts

How could i make a scrolling background in Game Maker. When Sonic moves forward or backwards. The background scrolls with him. But if sonic moves upwards or downwards the background does not scroll with him. How could i make that possible.

Link to comment
Share on other sites

I don't use GameMaker so often so I'm not aware how it handles backgrounds.

However... can you assign values to a background object?

At the start of the level, set two values to the background object's x and its y respectively

During runtime, set the X to s*a + x, where s is the leftmost pixel visible on the screen and a is a number that determines how fast it will scroll. Experiment to find a good one. X is the value you set to the x at the start of the level.

Vertical scrolling (which in this case you don't want) is similar, except you set Y to the topmost pixel * whatever + y

Link to comment
Share on other sites

Remembering on the last time I used Game Maker, I'd set the background_x to the View_left and the background_Y to the View_right * 0.5 or whatever you want to make it ( multiplying it by 0 would make it not scroll at all ). Those may not be the exact value names, but I do know they exist if you search for them in the gm list of functions. I'm quite sure as I was able to make use of them for paralax backgrounds in my gm5 tutorial.

Link to comment
Share on other sites

You could alter the background views directly (namely background_x[w/e] and background_y[w/e]), but my experience is there's a lag between the drawing and the updating of these coordinates, so you get a jerky background.

Instead, what you should do is have an object with extremely high depth draw the background at the correct coordinates. And those coordinates are simply a constant for the x (probable 0) and view_yview[0] for the y.

If you wanted to add a little parralax to the x or y coordinates (parralax is how, as you move forward, the background moves forward, but at a slower rate than you), then what you do is have the x coordinate as "view_xview[0]*(0.9)". You can change "(0.9)" to another value between 0 and 2 or so to make it look just right.

Here's what the code should look something like:

draw_background_tiled( background0 , view_xview[0]*0.9 , view_yview[0] );

Link to comment
Share on other sites

The technical definition of parallax is the inference of depth in the scrolling of objects past a given view. Objects that are farther away will appear to move more slowly.

If that's at me, I already know, otherwise what I said wouldn't have made much sense.

@ Kain: Would that slow down the game; using an object? Cause if it doesn't, that would fix the jerky background I experience and finally make my engine tutorial the way I want it to be. Although how would I make the background loop endlessly?

Link to comment
Share on other sites

Not in recent Game Makers, at least. In my tests, there were no notible speed differences between drawing the background(s) yourself and letting GM do it. The only problem is there's no function to only tile it vertically or horizontall, so you have to make one yourself. I'm not sure about GM5-, though. Just don't forget to deactivate the real background or you'll end up drawing backgrounds twice.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...