Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Fri 16/12/2005 08:13:38

Title: same regions detecting (solved)
Post by: on Fri 16/12/2005 08:13:38
In my game Bob's busking nightmare, there are a few instances where bob is busking and the police come to hassle him.
at the moment I have used collisions etc but it is not what I am looking for.
It would be better if a few yards away from the player the police hassle script jumps in, that is before a collision. maybe using regions.
How can I have a script which detects that player is in same region as the policeman???
Title: Re: same regions detecting
Post by: Gilbert on Fri 16/12/2005 09:01:32
Something like:

if (Region.GetAtRoomXY(player.x, player.y)==Region.GetAtRoomXY(cPolice.x, cPolice.x)) {
Ã,  blah blablabla
}
Title: Re: same regions detecting
Post by: monkey0506 on Fri 16/12/2005 22:14:11
You also might want to make sure that those aren't both null (just checking one would work) because if they are both null then it would return true...
Title: Re: same regions detecting
Post by: Ashen on Sat 17/12/2005 15:25:51
Regions are the best choice if there's a specific spot Bob will be standing on to busk (e.g. he moves there when you start him busking). However, if he can just start playing wherever he's stood, you might be better just checking against the character's coordinates, e.g.:

if (cPolice.x > (cBob.x-75) && cPolice.x < (cBob.x+75)) {
  // Start hassling
}

This would start the hassling if the Police character was less than 75 pixels left or right of Bob. Depending on the background(s) used, you could also add a check on the Y position.
Title: Re: same regions detecting
Post by: on Sat 17/12/2005 20:44:01
thanks everyone it works as I wanted, in fact ive put regions on all the relevant areas so that bob is hassled if the police are within haearing distance about 75 pixels away. I'm now very happy until my next problem
lol