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?
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.
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
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.
Thank-you that worked ;D