Windows how to make a room loop infinitely?

K

kingjohnc19

Guest
I want to make a simple infinite platformer game with a camera that follows the player. How do I make a room that seamlessly loops without any sort of transition?
 
That is not going to be easy, it's not something that Gamemaker offers by default. The closest thing it has is where room wrapping, where once the player moves outside the room they are moved back to the beginning of the room on the opposite side that they existed. What you want I believe is infinite tiling, where the room just appears to go on forever.

There are a lot of ways you can go about this because it's a rather ambiguous problem. But, essentially you need to create some sort of tiling of "rooms", but you can't use Gamemaker Rooms because you can't have more than one active at a time so you will need to make up your own room system. Then, you basically need to juggle three rooms at a time, the previous room, the current room and the next room, but only 2 of the 3 will ever be active at once. Then, you have to move the rooms around the player, not the player around the room. Then, you have to watch for the camera views placement in the room, if the right end of the view is say 32 pixels away from the right end of the current room then you activate the next room, and move it alongside the current one. Then, once the next view is within the scope of the camera you would shift your three juggling rooms over 1, meaning the previous room is dropped, the current room becomes the previous room, the next room becomes the current room and you shift a new room onto the end for the next room.

This whole thing is very complicated though, and I would consider it in the realm of advanced programming. The only suggestion I would have other than the above is to search online for an existing asset, there is likely something out there that does this already.
 

FrostyCat

Member
Do a tutorial on scrolling shooters and you'll see how it's done. The point is not to have an infinite room that a player moves through, the point is to have a finite-sized room where things in the background move and the player stays put. Getting a room to "loop" is simply a matter of generating the right things in the background at the right time.
 
Well I think it might depend on what exactly you want to do because I assume they actually want an infinitely generated room. They could just do like your saying and keep track of the objects and what not but that will not be very versatile, you need to compartmentalize the objects into custom groups/rooms and then have the objects follow the room they in. Then have the rooms like I mentioned above. You'll need too keep some map of the rooms though as you don't actually want everything running in the background, only a few rooms at once.

If you were really wanting to make an infinite room where the player can travel left or right infinitely then you would want to do it like this I'm guessing. Reason being it's easier to keep track of tiling rooms than all the individual objects that make up your room. Plus this way you can create a bunch of well thought out room variations and tile them together in a pleasing way, otherwise your looking at some complications algorithm to continually place new objects in some organized fashion. Plus if your planning on having multiple levels with various complicated objects, paths and events then your really going to need a way to organize everything appropriately. Also if you group things like this you can do all the management through the group and have it Auto affect everything in the room. So 6 months from now when you want to add a new object to the room you don't have to go back through all your complicated code to try and remember how to add new objects to be auto generated in the right places, instead you just place it appropriately within the various room chunks you have defined manually. Alternatively you could make the room chunks generate procedurally if you wanted, just depends.
 
Top