MFGG Forums
I found a tutorial for parallax scrolling, and i have code, but i have a new problem. - Printable Version

+- MFGG Forums (https://forums.mfgg.net)
+-- Forum: MFGG (https://forums.mfgg.net/forumdisplay.php?fid=4)
+--- Forum: Developer Discussion (https://forums.mfgg.net/forumdisplay.php?fid=10)
+--- Thread: I found a tutorial for parallax scrolling, and i have code, but i have a new problem. (/showthread.php?tid=2696)



I found a tutorial for parallax scrolling, and i have code, but i have a new problem. - Videogamejunkie443 - 05-24-2021

I got code for parallax scrolling from this youtube video: Game Maker Controlled Parallax Scrolling Tutorial - YouTube, but I want the backgrounds to scroll at the same speed as in SMB1 in Super Mario All-Stars. I would like somebody to modify the code to meet these conditions. here's the code:

background_x[0] = view_xview[0] * 0.6
background_x[1] = view_xview[0] * 0.4

Thank you.

(05-24-2021, 10:29 PM)dreemurr555 Wrote: I got code for parallax scrolling from this youtube video: Game Maker Controlled Parallax Scrolling Tutorial - YouTube, but I want the backgrounds to scroll at the same speed as in SMB1 in Super Mario All-Stars. I would like somebody to modify the code to meet these conditions. here's the code:

background_x[0] = view_xview[0] * 0.6
background_x[1] = view_xview[0] * 0.4

Thank you.

I think the above code is it, but I don't know.


RE: I found a tutorial for parallax scrolling, and i have code, but i have a new problem. - Simpson55 - 05-25-2021

You have to give more information about your code.
Did you define background[0] and background[1] in the room editor or in the code?
You should also make sure that both backgrounds are set to "repeated".
As for the speed, you can tweak the 0.4 and 0.6 constants until it looks about right. The lower the constant is, the faster the scrolling will be.


RE: I found a tutorial for parallax scrolling, and i have code, but i have a new problem. - Videogamejunkie443 - 05-25-2021

(05-25-2021, 12:41 AM)Simpson55 Wrote: You have to give more information about your code.
Did you define background[0] and background[1] in the room editor or in the code?
You should also make sure that both backgrounds are set to "repeated".
As for the speed, you can tweak the 0.4 and 0.6 constants until it looks about right. The lower the constant is, the faster the scrolling will be.

Okay, first things first, I'm using Hello Mario Engine for Game Maker Studio & Hello Engine 6 Fan-Made for Game Maker 8/8.1. The All-Stars Rooms have 3 backgrounds. Background 0 is the sky, Background 1 is the clouds, and Background 2 is the hills. The object I created was made to be placed in a room. This would make backgrounds 1 and 2 move. So far, everything looks good. Also, I don't think I need to worry about the backgrounds repeating, but if you still want to know, they do repeat.


RE: I found a tutorial for parallax scrolling, and i have code, but i have a new problem. - Simpson55 - 05-25-2021

They do need to repeat!
[Image: khxp.png]
See, the background position is view_xview[0] * C, where C is a constant between 0 and 1. Thus the background's position is always to the left of the view. So if you don't enable the repetion, the background won't be visible.
By the way, I'm not familiar with Hello Engine but isn't there already an option for parallax scrolling?


RE: I found a tutorial for parallax scrolling, and i have code, but i have a new problem. - Videogamejunkie443 - 05-25-2021

(05-25-2021, 12:04 PM)Simpson55 Wrote: They do need to repeat!
[Image: khxp.png]
See, the background position is view_xview[0] * C, where C is a constant between 0 and 1. Thus the background's position is always to the left of the view. So if you don't enable the repetion, the background won't be visible.
By the way, I'm not familiar with Hello Engine but isn't there already an option for parallax scrolling?

As I said, the backgrounds repeat, so I don't need to worry. And if the engine already has a way to make the background scroll like that, I couldn't find the code that let's me do it, so I made a custom object that does just that.


RE: I found a tutorial for parallax scrolling, and i have code, but i have a new problem. - Simpson55 - 05-25-2021

Then I guess you should take a look at the objects that control the camera and/or the background, assuming they do exist.


RE: I found a tutorial for parallax scrolling, and i have code, but i have a new problem. - Videogamejunkie443 - 05-25-2021

(05-25-2021, 05:09 PM)Simpson55 Wrote: Then I guess you should take a look at the objects that control the camera and/or the background, assuming they do exist.

GateteVerde might know what to do. And he might even know where to find the original scrolling object. I'm sorry to bring you into this, but I know you've made a Super Mario All-Stars SMB1 engine for both Game Maker 8/8.1 and Game Maker Studio 1.4 and I thought you would be able to help.


RE: I found a tutorial for parallax scrolling, and i have code, but i have a new problem. - OssieTheOstrich - 05-26-2021

@dreemurr555 I don't wanna sound rude, but I think you should probably ask this in the MFGG discord (if you are old enough to make a discord account though) instead of making multiple threads for your game dev issues. Since discord is real time, you'll probably get help quicker, and probably from more people.


RE: I found a tutorial for parallax scrolling, and i have code, but i have a new problem. - Gate - 05-26-2021

@dreemurr555 If you are still using Hello's Engine, the parallax codes should be somewhere on obj_levelmanager End Step event.


This forum uses Lukasz Tkacz MyBB addons.