Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: alisa_tana on Sun 16/01/2011 18:47:46

Title: Check a range for GetHotSpot? [Resolved]
Post by: alisa_tana on Sun 16/01/2011 18:47:46
Is there a quick and simple way of checking a range of pixels for the GetHotSpotAt, rather than just a single x and y coordinate?

To say, I'm checking the hotspots at cEgo's y, but I want to check for the hotspots anywhere between cEgo.y+10 to cEgo.y-10, without having to repeat the If statement 20 times.
Title: Re: Check a range for GetHotSpot?
Post by: Wyz on Sun 16/01/2011 19:44:32
It depends on what you're trying to accomplish really but no, there is no other way except calling the function. However, it might be possible to optimize the number of times you need to call it though.
The basic code would be this:


int y = cEgo.y - 9;
while (y < 10)
{
   if (HotSpot.GetAtScreenXY(cEgo.x - Room.GetViewportX(), y - Room.GetViewportY()) == SOMETHING)
       doSomething();
   
   y++;
}
Title: Re: Check a range for GetHotSpot?
Post by: alisa_tana on Sun 16/01/2011 19:47:48
Okay.  I had a feeling it'd be something like that, but I'd managed to forget the syntax for the whole "while" thing.
Title: Re: Check a range for GetHotSpot?
Post by: Khris on Mon 17/01/2011 03:13:23
It's supposed to be:

  while (y < cEgo.y + 10)

and

  GetViewportX(), GetViewportY()
Title: Re: Check a range for GetHotSpot?
Post by: alisa_tana on Mon 17/01/2011 03:19:49
Yeah, I got the right coding for those parts already, it was more the "while" part that I'd forgotten how to do.

now I've just got to tweak the exact range it checks.   Thanks!