I already have a basic platformer with levels setup but I want to make an endless gamemode, heres what I want to be able to do: I want to randomly generate preset chunks side by side to make an endless runner, I don't want to make random terrain but preset structures in a random order infinitely.
This is a terrible solution (take the word "solution" with a grain of salt). And it's probably the most inelegant approach ever:
I created a background sprite that tiles horizontally. I made the room double the width of that sprite. I gave the room that background and checked "horizontally tile".
I then placed two objects, obj_wrap_right, obj_wrap_left. As long as you place them away from the sides then the view won't snap. I placed the wrap objects in the exact same location in terms of where they match up.
So let's say there's a mountain in your background. That mountain will appear twice, because you tiled the background twice. So place obj_wrap_right at the right mountain, and obj_wrap_left at the left mountain. Snap the player to the left when he reaches the right. Because obj_wrap_left is far enough away from the left side of the room, you won't notice the change in position.
Code:
// Move to the right object
x += min(5, point_distance(x, 0, obj_wrap_right.x, 0));
// Are you there? Wrap to the left object
if (x == obj_wrap_right.x)
{
x = obj_wrap_left.x;
}
Obviously, I didn't do the left side. And let me restate, I just did this real quick like so yeah. But let me know if you try it and it works / helps.