Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Virgil on Wed 07/10/2009 22:55:36

Title: Prevent players from leaving a region *(Solved)
Post by: Virgil on Wed 07/10/2009 22:55:36
I want to have a setting so that a player can't leave a region. I've done some fiddling around with global boolean variables and cCharacter.Stop Moving, but when I try to leave, it just stops, then I can continue on. Surely there must be a way to totally prevent a character from leaving a region?
Title: Re: Prevent players from leaving a region
Post by: Crimson Wizard on Wed 07/10/2009 23:16:47
Quote from: Virgil on Wed 07/10/2009 22:55:36
I want to have a setting so that a player can't leave a region. I've done some fiddling around with global boolean variables and cCharacter.Stop Moving, but when I try to leave, it just stops, then I can continue on. Surely there must be a way to totally prevent a character from leaving a region?

There is this way: try to make character return inside the region either by walking or teleporting 1 to few pixels back.

Like this:

cEgo.StopMoving();
if (cEgo.x <= RegionLeftBorder)
{
  cEgo.x = RegionLeftBorder + 1;
}
if (cEgo.x >= RegionRightBorder)
{
  cEgo.x = RegionRightBorder - 1;
}

etc
Title: Re: Prevent players from leaving a region
Post by: Virgil on Wed 07/10/2009 23:26:20
Oh, that works great. I suppose the only hitch is that the screen shutters since its longer than the viewport. Oh, well, I don't think there's anything I can do about it.
Title: Re: Prevent players from leaving a region
Post by: Khris on Thu 08/10/2009 00:13:19
There is, just use more than one walkable area and deactivate the one(s) outside the region.
Title: Re: Prevent players from leaving a region
Post by: Virgil on Thu 08/10/2009 01:31:09
Yes, I know about that, but it wouldn't have worked for what I have planned.

In fact I may not even have to use this, its more of a contingency plan. I still learned something though.
Title: Re: Prevent players from leaving a region
Post by: Crimson Wizard on Thu 08/10/2009 13:27:18
Quote from: Khris on Thu 08/10/2009 00:13:19
There is, just use more than one walkable area and deactivate the one(s) outside the region.
I feel dumb... ;)

Quote from: VirgilYes, I know about that, but it wouldn't have worked for what I have planned.
Hmm.. why?
Title: Re: Prevent players from leaving a region
Post by: Virgil on Thu 08/10/2009 14:29:54
 ;)

Simply what I have planned. Though I most likely won't use it. Thanks for you help anyway.