• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Create a loop (MAP)

TheDuke21

Member
Hello, I am French, please excuse me in advance for the mistakes.

I would like to know how to create a loop between the start and the end of the level (infinite level)

thank you in advance for your help.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
We need to know a LOT more about the game! What kind of game is it? A vertical scrolling shooter? A platformer? A defender type game? Before we can offer any suggestions we really need to know in detail what it is you want to do... :)
 

TheDuke21

Member
it's a 2D platform game, I would like to make an open world, I would just have to know how to connect the beginning of the map and the end to make an infinite loop, I'm sorry if I express myself badly, I hope at least I was understandable
:)
 

TheouAegis

Member
Design your room so at least ½ screen's width of the beginning is the same as the end, and ½ screen-width of the end is the beginning. If the player's x is less than the actual beginning of the room (not 0), move every instance one room width (not room_width) to the right. Likewise, if the player x is greater than the actual end of the room (again, not room_width), move everything to the left one room width.

Bit more difficult with multiplayer.
 

TheDuke21

Member
Design your room so at least ½ screen's width of the beginning is the same as the end, and ½ screen-width of the end is the beginning. If the player's x is less than the actual beginning of the room (not 0), move every instance one room width (not room_width) to the right. Likewise, if the player x is greater than the actual end of the room (again, not room_width), move everything to the left one room width.

Bit more difficult with multiplayer.

so thank you for your answer, but i'm looking for a line of code to do this, it would be easier for me. Especially since I'm not sure I understood everything you told me to make an infinite map like an open world. If someone maybe has sites for programming.

Do you have a tutorial on the internet to better explain your answer to me? thank you in advance again for your help :)
 
D

Deleted member 13992

Guest
Is the game world over many rooms or is it all in one room?

Do you want the loop to be completely seamless/invisible to the player? Or is it fine to have a transition (such as a fade to black)?

Are there enemies or objects that move around that might be visible at the end/start?
 

TheDuke21

Member
Is the game world over many rooms or is it all in one room?

Do you want the loop to be completely seamless/invisible to the player? Or is it fine to have a transition (such as a fade to black)?

Are there enemies or objects that move around that might be visible at the end/start?
so, its a one room, invisible to the player and yes for last question :) :)

my concept is to create a game for my 4-year-old twin, she embodies a unicorn, which attacks automatically, I have started to program a game with the least possible interaction so that she can play freely.
 

woods

Member
something to get your started with at least... oversimplified example here ;o)
lets say you have a room that is 2000 wide, and your player starts on the left side of the room...


if (player.x >= 2000)
{
player.x = 0;
}

when the player gets to the far right, (2000 on the x coord) this would effectively wrap your player back to the starting(left) side of the room
 

TheDuke21

Member
so that we can agree on the style I want here is an example, if you know "BRAIN / OUT" you will understand what I want as open world if not go see this game available on steam for free.
 

woods

Member
@Amon for the win!

a simple move_wrap()
the example in the manual is EXACTLY what you want.. dropped in the player step event
 

TheouAegis

Member
move_wrap isn't seamless, it is very garish. It makes more sense with NPCs than the player. The player needs to keep the "view" intact.

Code:
if x < camera_get_view_width(view_camera[0])/2 {
    x += room_width - camera_get_view_width(view_camera[0]);
}
else
if x > room_width - camera_get_view_width(view_camera[0])/2 {
      x -= room_width - camera_get_view_width(view_camera[0])
}
And then design your room so the last screen is duplicated at the beginning and the first screen is duplicated at the end.

The alternative is to use data-based tile placement.
 

TheDuke21

Member
move_wrap isn't seamless, it is very garish. It makes more sense with NPCs than the player. The player needs to keep the "view" intact.

Code:
if x < camera_get_view_width(view_camera[0])/2 {
    x += room_width - camera_get_view_width(view_camera[0]);
}
else
if x > room_width - camera_get_view_width(view_camera[0])/2 {
      x -= room_width - camera_get_view_width(view_camera[0])
}
And then design your room so the last screen is duplicated at the beginning and the first screen is duplicated at the end.

The alternative is to use data-based tile placement.

thank you all for your help, your code looks a lot cleaner to me but i will also try move_wrap, i would take the one that suits me best even if i already have an idea which one ;)
 

Welvex

Member
move_wrap isn't seamless, it is very garish. It makes more sense with NPCs than the player. The player needs to keep the "view" intact.

Code:
if x < camera_get_view_width(view_camera[0])/2 {
    x += room_width - camera_get_view_width(view_camera[0]);
}
else
if x > room_width - camera_get_view_width(view_camera[0])/2 {
      x -= room_width - camera_get_view_width(view_camera[0])
}
And then design your room so the last screen is duplicated at the beginning and the first screen is duplicated at the end.

The alternative is to use data-based tile placement.
I tried your code and I like how it works, however it is not clean as expected, it has a few pixels lag, how could I solve that? to make it look really clean
Example:
It is not very noticeable, but in the game it is much more noticeable
 
Last edited:

TheouAegis

Member
You're right, it's not very noticeable. What am I looking at, exactly?

Make sure you wrap the player after moving, not before. Make sure you update the camera immediately after wrapping the player. Also, make sure you added a buffer to each side of the room that is precisely half the width of the camera's view (which you probably did, since you're using tiles, but it's still important).
 
Last edited:
Top