• 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!

Legacy GM Wrapping the room perfectly

P

Phocoena Studio

Guest
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.
 

Roderick

Member
Open your player object, and add a draw event. In it add
Code:
draw_self();
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:
The Manual said:
Note that the instance must have a speed for wrapping to work, because the direction of wrapping is based on the direction of the motion.
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:
Top