Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: barefoot on Wed 09/06/2010 21:24:17

Title: SOLVED: when Object x y meets condition then another action happens
Post by: barefoot on Wed 09/06/2010 21:24:17
Hi

Ive used the Object.GetAtScreenXY but to no avail..

I have some Objects with each one set to Int Random Moves.. which works fine..  

Now I need to check when a certain Object moves to one of the int random options it then carry's out an 'if'...

eg:
if Object A moves to x y coordinates then AddInventory.....  etc

Code I have at the moment:

function oyellcirc_Interact()
{
int ran=Random(5);
if (ran==0) object[1].Move(134, 292, 4, eBlock, eAnywhere);
else if (ran==1) object[1].Move(206, 285, 4, eBlock, eAnywhere);
else if (ran==2) object[1].Move(269, 284, 4, eBlock, eAnywhere);
else if (ran==3) object[1].Move(320, 274, 4, eBlock, eAnywhere);
else if (ran==4) object[1].Move(360, 294, 4, eBlock, eAnywhere);
else if (ran==5) object[1].Move(217, 344, 4, eBlock, eAnywhere);
else object[1].Move(146, 298, 4, eBlock, eAnywhere);
}


Hope this is understandable

barefoot
Title: Re: when Object x y meets condition then another action happens
Post by: Vince Twelve on Wed 09/06/2010 22:07:17
You'll want to use

if(object[1].x==360 && object[1].y==294){
...
}


GetAtScreenXY is asking for finding out, basically, if you pointed your mouse at these X,Y coordinates, would you be touching an object?  So, if you have transparency in the object's graphic in the lower left corner, GetAtScreenXY wouldn't find it.

But like I showed in that other thread, since the movement is blocking, if you want an action to happen immediately when the object reaches one of the destinations, you can just put the commands in the same block of code:


  if(ran==2){
    oObject.Move(320, 202, 5, eBlock);
    oDoor.Graphic=50; //or whatever code you want to reach after the object reaches this destination
  }

Title: Re: when Object x y meets condition then another action happens
Post by: barefoot on Wed 09/06/2010 23:34:02
Cheers Vince.. brill...

x has to be X

:=

barefoot