Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: De-Communizer on Thu 24/12/2009 12:46:14

Title: Moving a character to the opposite side of the screen...
Post by: De-Communizer on Thu 24/12/2009 12:46:14
I'm sure I remember, and that I'm not just imagining it, that years ago on 2.7 and before I could make a room loop around when a character walked too far to one side. Having been unable to figure that out these days, I've resorted to something else.

My resolution is 320x240, but my room is 640 in width. As the character moves (with pressed arrow keys), the view follows them, and when they get to the edge, I told it to do this:

if (player.x>640)cEgo.x=-3;
if (player.x<0)cEgo.x=643;

Nothing seems to be happening, though. I've a feeling that it's something to do with the Viewport? No idea though, but I'd be most gracious if someone could point me in the right direction.

Merci beaucoup, and Merry Christmas!
Title: Re: Moving a character to the opposite side of the screen...
Post by: Gilbert on Thu 24/12/2009 12:52:43
Where did you put the codes? Did you put them in repeatedly_execute() or other events?
Title: Re: Moving a character to the opposite side of the screen...
Post by: De-Communizer on Thu 24/12/2009 13:01:40
They were initially in a function being repeatedly executed. I moved them out into repeatedly_execute on their own, but still no joy.
Title: Re: Moving a character to the opposite side of the screen...
Post by: Crimson Wizard on Thu 24/12/2009 13:59:48
Quote
My resolution is 320x240, but my room is 640 in width. As the character moves (with pressed arrow keys), the view follows them, and when they get to the edge, I told it to do this:

if (player.x>640)cEgo.x=-3;
if (player.x<0)cEgo.x=643;

Nothing seems to be happening, though

Do you mean that character does not change the coordinates?
Character cannot actually leave the walkable area (unless told to walk "anywhere"), so if you do not use "eAnywhere" option for walking, your character will never pass by 0 or 639 coordinate.
If you don't like him/her to walk "anywhere", you may change condition to, like

if (player.x>=639) and if (player.x<=0)

Viewport shouldn't be a problem here, because even locking Viewport at cettain position won't prevent character from changing its position.
Title: Re: Moving a character to the opposite side of the screen...
Post by: De-Communizer on Thu 24/12/2009 14:20:08
Ohhh, I see. I thought I'd told it to not care about walkable areas, but that's what I'd overlooked. I guess I'm just being silly tonight!