need help w/ a code to move people

Started by mport2004, Wed 04/05/2005 02:26:21

Previous topic - Next topic

mport2004

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;
}
???

Scummbuddy

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
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Pumaman

Are all your int variables declared at the top of the script, outside the function?

mport2004

i put the int vars at top o script and its still doing it.

Pumaman

Are you sure you don't have any other code, for example in on_key_press, that might be causing this?

mport2004

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.

SMF spam blocked by CleanTalk