1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GM:S 1.4 Wrapping the room perfectly

Discussion in 'Programming' started by Phocoena Studio, Dec 20, 2016.

  1. Hi, guys.

    I am currently making some games and now I am stuck.

    I wanted to wrap the room, so I just used the drag & drop of room wrap at first.

    Then when I actually test it, I realised it's not actually perfect.

    What I mean by perfect is, there is no space outside the room, and when object goes half outside room, the other half will show at the opposite side of the room.

    But the drag & drop of room wrap did not do that.

    So I tried to use move_wrap function.

    But, It doesn't work properly, eventhough I tried lots of different margins.

    Please help me. Thanks.
  2. Roderick

    Roderick Member

    Jun 22, 2016
    Open your player object, and add a draw event. In it add
    draw_sprite(sprite_index, image_index, x - room_width, y);
    draw_sprite(sprite_index, image_index, x + room_width, y); 
    This will make your player object draw itself normally, and then draw a copy of itself one room ahead and one room behind its actual position. These two will be offscreen and not visible until you get to the edge of the screen; then the part that corresponds to the part of the player sprite that is offscreen will be onscreen, giving the illusion of a wrap.

    This only does horizontal. If you want vertical, you'll need to add additional lines for that, which means you'd probably need diagonals as well.

    If you're concerned about slowdown from too many draws per step, you can add conditionals so that it only draws the extra sprites when needed.

    I think this can be done via Drag and Drop, but if it can, I'm not sure the specifics.

    Edit: I just looked over move_wrap, which I've never used before, and if you're using it properly, it should do exactly what you want. Could you post your move_wrap code?
    And remember this if you're using move_wrap:
    If you're manually moving the object, move_wrap won't work; you need to use the built-in speed and direction variables to use it.
    Last edited: Dec 20, 2016

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice