Mr.S Posted November 25, 2006 Report Share Posted November 25, 2006 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 More sharing options...
Draco Icebane Posted November 25, 2006 Report Share Posted November 25, 2006 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 More sharing options...
USC Posted November 25, 2006 Report Share Posted November 25, 2006 Umm...could you post your scrolling code? Without seeing it, all I can say is do the same thing as scrolling from left to right, only refer to the Y position (vertical), not the X position (horizontal). [Edit : A bit late, I guess] Link to comment Share on other sites More sharing options...
LarkSS Posted November 25, 2006 Report Share Posted November 25, 2006 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 More sharing options...
Kain Posted November 25, 2006 Report Share Posted November 25, 2006 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 More sharing options...
Draco Icebane Posted November 25, 2006 Report Share Posted November 25, 2006 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. Link to comment Share on other sites More sharing options...
LarkSS Posted November 25, 2006 Report Share Posted November 25, 2006 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 More sharing options...
Kain Posted November 26, 2006 Report Share Posted November 26, 2006 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 More sharing options...
LarkSS Posted November 26, 2006 Report Share Posted November 26, 2006 I'm using GM5, but I'll give it a shot anyway. Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts