Prevent players from leaving a region *(Solved)

Started by Virgil, Wed 07/10/2009 22:55:36

Previous topic - Next topic

Virgil

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?

Crimson Wizard

#1
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

Virgil

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.

Khris

There is, just use more than one walkable area and deactivate the one(s) outside the region.

Virgil

#4
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.

Crimson Wizard

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?

Virgil

 ;)

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

SMF spam blocked by CleanTalk