Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Creator on Sat 13/01/2007 03:40:51

Title: How do you make a 2-Player Game? (SOLVED)
Post by: Creator on Sat 13/01/2007 03:40:51
I've been experimenting with a 2-Player game with AGS.
I just can't figure out the second players controls.

this is my code


if (cBill.Room == player.Room) {
if (keycode==87) { // W
   cBill.WalkStraight(cBill.x, cBill.y-200,eNoBlock);
   while ((IsKeyPressed(372)>0) && (cBill.Moving))
    cBill.StopMoving();
}

if (keycode==65) { // A
    cBill.WalkStraight(cBill.x-200, cBill.y,eNoBlock);
   while ((IsKeyPressed(372)>0) && (cBill.Moving))
    cBill.StopMoving();
}

if (keycode==68) { // D
    cBill.WalkStraight(cBill.x+200, cBill.y,eNoBlock);
    while ((IsKeyPressed(372)>0) && (cBill.Moving))
    cBill.StopMoving();
}

if (keycode==83) { // S
    cBill.WalkStraight(cBill.x, cBill.y+200,eNoBlock);
    while ((IsKeyPressed(372)>0) && (cBill.Moving))
      cBill.StopMoving();
}
}

But I can't make it when the player presses W,S,A or D a second time bill stops moving.
Can someone help me please?
Title: Re: How do you make a 2-Player Game?
Post by: Khris on Sat 13/01/2007 04:09:47
if (keycode==87) { // W
   cBill.WalkStraight(cBill.x, cBill.y-200,eNoBlock);
   while ((IsKeyPressed(87)>0) && (cBill.Moving))    // check for W, not 372 i.e. Up arrow
    cBill.StopMoving();
}

Same for the other three.
Title: Re: How do you make a 2-Player Game?
Post by: Creator on Sat 13/01/2007 09:51:44
Quote from: KhrisMUC on Sat 13/01/2007 04:09:47
if (keycode==87) { // W
   cBill.WalkStraight(cBill.x, cBill.y-200,eNoBlock);
   while ((IsKeyPressed(87)>0) && (cBill.Moving))    // check for W, not 372 i.e. Up arrow
    cBill.StopMoving();
}

Same for the other three.

This doesn't work either
Title: Re: How do you make a 2-Player Game?
Post by: Akatosh on Sat 13/01/2007 10:19:24
Well, I'd try

if (keycode==87) { // W
if (cBill.Moving==true) cBill.StopMoving();
else cBill.WalkStraight(cBill.x, cBill.y-200,eNoBlock);
}


When you hit W and he's standing, he starts walking. If he's already walking, he stops doing so.
Title: Re: How do you make a 2-Player Game?
Post by: Creator on Sat 13/01/2007 10:35:04
Thank-you that worked ;D