How do you make a 2-Player Game? (SOLVED)

Started by Creator, Sat 13/01/2007 03:40:51

Previous topic - Next topic

Creator

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

Code: ags

 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?

Khris

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.

Creator

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

Akatosh

Well, I'd try
Code: ags

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.

Creator


SMF spam blocked by CleanTalk