Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: geork on Thu 28/05/2009 14:26:00

Title: eKey question
Post by: geork on Thu 28/05/2009 14:26:00
 Hey all
   I am trying to make something happen when the user presses a key, and only for that room. I got the code and the claim event, but apparentely I need to include a function or something (the index wasn't clear): on_key_press. how do I create a code that only works for that room? I tried:
if(keycode == eKeyRightArrow){
    cEgo.Walk(cEgo.x - 40, cEgo, eBlock, eWalkableAreas);
    ClaimEvent();
  }
, but it didn't recognize 'keycode'
        thanks
Title: Re: eKey question
Post by: Matti on Thu 28/05/2009 14:39:44
Try:


if (IsKeyPressed(377) == 1){
 cEgo.Walk(cEgo.x - 40, cEgo, eBlock, eWalkableAreas);
 ClaimEvent();
}


377 is the ASCII-code for the right arrow. The Code table can be found in the manual.

But is the player supposed to go to the left when the player uses the right arrow key?
Title: Re: eKey question
Post by: geork on Thu 28/05/2009 14:43:37
cool, thanks!
Title: Re: eKey question
Post by: Trent R on Thu 28/05/2009 15:06:48
function on_key_press(eKeyCode keycode) {
  if(keycode == eKeyRightArrow){
    cEgo.Walk(cEgo.x - 40, cEgo, eBlock, eWalkableAreas);
    ClaimEvent();
  }
}


Should work just fine... And IsKeyPressed AKAIK is basically used for rep_exec events.


~Trent