Check a range for GetHotSpot? [Resolved]

Started by alisa_tana, Sun 16/01/2011 18:47:46

Previous topic - Next topic

alisa_tana

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.

Wyz

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

Code: ags

int y = cEgo.y - 9;
while (y < 10)
{
    if (HotSpot.GetAtScreenXY(cEgo.x - Room.GetViewportX(), y - Room.GetViewportY()) == SOMETHING)
        doSomething();
    
    y++;
}
Life is like an adventure without the pixel hunts.

alisa_tana

Okay.  I had a feeling it'd be something like that, but I'd managed to forget the syntax for the whole "while" thing.

Khris

It's supposed to be:

Code: ags
  while (y < cEgo.y + 10)


and

Code: ags
  GetViewportX(), GetViewportY()

alisa_tana

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!

SMF spam blocked by CleanTalk