SOLVED: Choosing more than 1 x and y for an Object

Started by barefoot, Wed 09/06/2010 19:26:10

Previous topic - Next topic

barefoot

Hi

Is it possible to choose more than 1 x and y for an Object... ie like an Int for Text giving random options?

Basically a player clicks a button which sets an Object to move.. what i am looking for is to be able to move that object from say 3 option random moves.

For example: Object Move: option1 300,190  option2 307,198 option3 320,202 etc etc

I want to check if that Object is at a certain x y location then set off another function such as door opening.

cheers
barefoot
I May Not Be Perfect but I Have A Big Heart ..

DrewCCU

#1
there is a function in AGS called Random.  Here is the help file info on it (should be useful to you):

Random

Code: ags
Random (int max)

Returns a random number between 0 and MAX. This could be useful to do various effects in your game.
NOTE: The range returned is inclusive - ie. if you do Random(3); then it can return 0, 1, 2 or 3.

Example:
Code: ags

int ran=Random(2);
if (ran==0) cEgo.ChangeRoom(1);
else if (ran==1) cEgo.ChangeRoom(2);
else cEgo.ChangeRoom(3);


will change the current room to room 1,2 or 3 depending on a random result.
"So much of what we do is ephemeral and quickly forgotten, even by ourselves, so it's gratifying to have something you have done linger in people's memories."
-John Williams

Vince Twelve

Code: ags

oObject_Interact(){
  int ran=Random(2); //random number from 0 to 2

  if(ran==0){
    oObject.Move(300, 190, 5, eBlock);
  }
  else if(ran==1){
    oObject.Move(307, 198, 5, eBlock);
  }
  else if(ran==2){
    oObject.Move(320, 202, 5, eBlock);
    oDoor.Graphic=50; //or whatever you do to open the door
  }
  
}


should get you on your way.

Edit: Drew beat me!  Stupid txt-style format filter, breaking my code!

barefoot

Cheers guys... works a treat..  :=

barefoot
I May Not Be Perfect but I Have A Big Heart ..

SMF spam blocked by CleanTalk