same regions detecting (solved)

Started by , Fri 16/12/2005 08:13:38

Previous topic - Next topic

eurobuskers

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???

Gilbert

Something like:

if (Region.GetAtRoomXY(player.x, player.y)==Region.GetAtRoomXY(cPolice.x, cPolice.x)) {
Ã,  blah blablabla
}

monkey0506

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

Ashen

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.:
Code: ags

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.
I know what you're thinking ... Don't think that.

eurobuskers

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

SMF spam blocked by CleanTalk