Hey there, I'm having a really weird movement problem in a script I'm writing that I just can't seem to figure out. Here is the code for it:
if($move == up) {
if($world[y]+1 == "") {
} else {
mysql_query("UPDATE players SET y=(y+1) WHERE username = '$userinfo[username]'");
}
} elseif($move == left) {
if($world[x]-1 == "") {
} else {
mysql_query("UPDATE players SET x=(x-1) WHERE username = '$userinfo[username]'");
}
} elseif($move == right) {
if($world[x]+1 == "") {
} else {
mysql_query("UPDATE players SET x=(x+1) WHERE username = '$userinfo[username]'");
}
} elseif($move == down) {
if($world[y]-1 == "") {
} else {
mysql_query("UPDATE players SET y=(y-1) WHERE username = '$userinfo[username]'");
}
}
On the game screen, I simply have 4 arrows that link to game.php?move=x. Now, this script should in theory simply move the character once in the direction they click, but here's the weird part, lets say I click up, it'll add +1 to the Y variable, but then I click right next, it'll still add +1 to Y, it's only after the 2nd time I click right that it'll add +1 to X. Same thing happens no matter what direction I go. Any clue what I'm doing wrong?