Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: mport2004 on Wed 04/05/2005 02:26:21

Title: need help w/ a code to move people
Post by: mport2004 on Wed 04/05/2005 02:26:21
im trying to make a 2player pong like game, but the code for the moving (for player one the arrow keys for player2 W is up S is down A is left  and D is right) when i move player one player 2 starts to move too.
heres my code


int cleft;  //flags to see if button is still pressed
int cright;
int cup;
int cdown;



                //the arrowkey code .
  if (IsKeyPressed(375)==1 && cleft==0) {
    cleft=1;
    MoveCharacterStraight(PA,-1000,character[PA].y);
  }
  if (IsKeyPressed(375)==0 && cleft==1){
    StopMoving(PA);
    cleft=0;
  }

  if (IsKeyPressed(377)==1 && cright==0) {
    cright=1;
    MoveCharacterStraight(PA,1000,character[PA].y);
  }
  if (IsKeyPressed(377)==0 && cright==1){
    StopMoving(PA);
    cright=0;
  }

  if (IsKeyPressed(372)==1 && cup==0) {
    cup=1;
    MoveCharacterStraight(PA,character[PA].x,-1000);
  }
  if (IsKeyPressed(372)==0 && cup==1){
    StopMoving(PA);
    cup=0;
  }

  if (IsKeyPressed(380)==1 && cdown==0) {
    cdown=1;
    MoveCharacterStraight(PA,character[PA].x,1000);
  }
  if (IsKeyPressed(380)==0 && cdown==1){
    StopMoving(PA);
    cdown=0;
}
//PB
int cleftb;
int crightb;
int cupb;
int cdownb;
           
  if (IsKeyPressed(65)==1 && cleftb==0) {
    cleftb=1;
    MoveCharacterStraight(PB,-1000,character[PB].y);
  }
  if (IsKeyPressed(65)==0 && cleftb==1){
    StopMoving(PB);
    cleftb=0;
  }

  if (IsKeyPressed(68)==1 && crightb==0) {
    crightb=1;
    MoveCharacterStraight(PB,1000,character[PB].y);
  }
  if (IsKeyPressed(68)==0 && crightb==1){
    StopMoving(PB);
    crightb=0;
  }

  if (IsKeyPressed(87)==1 && cupb==0) {
    cupb=1;
    MoveCharacterStraight(PB,character[PB].x,-1000);
  }
  if (IsKeyPressed(87)==0 && cupb==1){
    StopMoving(PB);
    cupb=0;
  }

  if (IsKeyPressed(83)==1 && cdownb==0) {
    cdownb=1;
    MoveCharacterStraight(PB,character[PB].x,1000);
  }
  if (IsKeyPressed(83)==0 && cdownb==1){
    StopMoving(PB);
    cdownb=0;
}
???
Title: Re: need help w/ a code to move people
Post by: Scummbuddy on Wed 04/05/2005 03:15:27
you do know that a open source pong clone was released, like yesterday, right?

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=20585.0
Title: Re: need help w/ a code to move people
Post by: Pumaman on Wed 04/05/2005 18:16:29
Are all your int variables declared at the top of the script, outside the function?
Title: Re: need help w/ a code to move people
Post by: mport2004 on Wed 04/05/2005 22:59:59
i put the int vars at top o script and its still doing it.
Title: Re: need help w/ a code to move people
Post by: Pumaman on Thu 05/05/2005 18:26:52
Are you sure you don't have any other code, for example in on_key_press, that might be causing this?
Title: Re: need help w/ a code to move people
Post by: mport2004 on Thu 05/05/2005 23:09:48
um today i was looking at that and i found some random lines that was making it do that. i have no idea how they got there but thx for the help.