Sporkinator

object_parent Left Pressed Event

Dec 16th, 2011
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var obj;
  2. sound_play(sndClick); //click sound
  3. //Deselect all other objects
  4. sound_play(sndClick)
  5. selected = !selected; //toggle selected
  6. var count, obj, i; //temporary variables
  7. count = 0; //count starts at zero
  8. i = 0; //array index counter
  9. with (object_parent) //do the next code with all objects that have this as a parent
  10. {
  11.     if (selected) //if I am selected
  12.     {
  13.         count += 1; //increase the count
  14.         obj[i] = id; //store my ID in the array so we can access me later.
  15.         i += 1; //increase this for the next array index (won't ever be more than 2 isntances, 0 and 1)
  16.     }
  17. }
  18. if (count == 2) //when 2 objects are selected, let's find out if we matched them correctly
  19. {
  20.     if (obj[0].object_index == obj[1].opposite) //if obj[0] is indeed obj[1]'s opposite
  21.     {
  22.         with (obj[0]) fade_out(); //fade out the first one!
  23.         with (obj[1]) fade_out(); //fade out the second one!
  24.         sound_play(sndTada);
  25.     }
  26.     else //otherwise...
  27.     {
  28.         room_restart(); //start over!
  29.     }
  30.     deselect_all(); //now let's deselect all objects, just to make sure none are selected
  31. }
Advertisement
Add Comment
Please, Sign In to add comment