Object not disappearing (closed)

Started by BlueAngel, Sat 15/01/2011 09:25:55

Previous topic - Next topic

BlueAngel

Hi I am trying to make like a whack-a-mole game in my game. The player is trying to catch a crab. I really want it to appear random to but haven’t gotten so far jet.
This is my problem, after the player catch the crab it is still visible on the screen?
This is my code:
Code: ags

function room_RepExec()
{
  if (clock>0) {
    clock++;
  }
  if (clock==20){
    oCrab3.Transparency=0;
    object[2].Move(360, 230, 10, eNoBlock, eAnywhere);
    object[0].Move(324, 300, 10, eNoBlock, eAnywhere);
    //character[2].y = 287;
  }
    else if (clock==400) {
      oCrab3.Transparency=100;
      object[2].Move(140, 230, 10, eNoBlock, eAnywhere);
      oCrab2.Transparency=0;
      object[1].Move(448, 287, 10, eNoBlock, eAnywhere);
      
      //character[3].x = 448;
      //character[3].y = 287;
      
  }
    else if (clock==600) {
      oCrab2.Transparency=100;
      object[1].Move(500, 300, 10, eNoBlock, eAnywhere);
      oCrab1.Transparency=0;
      object[0].Move(224, 128, 10, eNoBlock, eAnywhere);
      
      //character[2].x = 224;
      //character[2].y = 128;
      
  }
    else if (clock==800){
      oCrab1.Transparency=100;
      oCrab2.Transparency=100;
      oCrab3.Transparency=100;
      clock=1;
    
  }
  
  
}


It must be because the game check the visible in the game repeat but I must have there or?
I use 9verb and AGS 3.2

this is the code on the crab:

Code: ags

function oCrab1_AnyClick()
{
  // LOOK AT
  if(UsedAction(eGA_LookAt)) {
    player.Say("Its a crab with catching claws");
  }
  // OPEN
  else if (UsedAction(eGA_Open)) {
    Unhandled();
  }  
  // CLOSE
  else if (UsedAction(eGA_Close)) {
    Unhandled();
  }  
  // USE
  else if(UsedAction(eGA_Use)) {
    Unhandled();
  }
  // Push
  else if(UsedAction(eGA_Push)) {
    Unhandled();
  }
  // Pull
  else if(UsedAction(eGA_Pull)) {
    Unhandled();
  }  
  // PICKUP
  else if(UsedAction(eGA_PickUp)) {
    player.Say("Finelly");
    oCrab1.Visible=false;
    cEgo.AddInventory(iCrab);
  }
  //USE INV
  else if(UsedAction(eGA_UseInv)) {
    Unhandled();
  }
  // don't forget this
  else Unhandled();
}


Calin Leafshade

youre only setting oCrab1.Visible to false.

you need to set the other crabs to invisible too maybe?


no wait, that makes no sense :/

Dualnames

Code: ags

  // PICKUP
  else if(UsedAction(eGA_PickUp)) {
    player.Say("Finelly");
    oCrab1.Visible=false;
    cEgo.AddInventory(iCrab);
  }


I'm having troubles understanding your problem.
1) You have a whack-a-mole part, that's handled in rep_exec of the room. Is that working?
2) Your problem is that after the player catches the crab with the code above been triggered, the crab is still visible?
3) Are you sure you're actually grabbing the crab? Do you get the "Finelly" message and the item in your inventory?
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

BlueAngel

#3
1.    yes the crabs are moving across the screen ( I really just need one)
2.   Yes, I want the crab to disappear after the player catch it.
3.   Yes its in the inventory

Thanks for trying to help me, there is probably a better way to do this.

BlueAngel

I gonna try this instead
Code: ags

// room script file


function room_Load()
{
  SetTimer(1, 400);
  cCrab1.Move (300, 300);
}

function room_RepExec()
{
  bool found;
  int x, y;
  

  if(!cCrab1.Moving){ //wait for the npc to stop moving !=not
    while (!found){
      x=Random(Room.Width);
      y=Random(Room.Height);
      if (Region.GetAtRoomXY(x,y)== region[1])found=true;
      }
      cCrab1.Walk(x, y, eNoBlock, eWalkableAreas);
     }
     }
}


SMF spam blocked by CleanTalk