|
I still don't see how to use it, or rather where to use it. Is it like player.dir? Why not just set player.dir = 1;?
|
PHP Code:
for (k=0;k<4;k++) {
if (keydown(k)) {
player.dir = k;
player.x += vecx(k);
player.y += vecy(k);
}
}
if the players dir is 0: x will raise by 0, y will lower by -1 (player walks up)
if the players dir is 1: x will lower by -1, y will raise by 0 (player walks to the left)
if the players dir is 2: x will raise by 0, y will raise by 1 (player walks down)
if the players dir is 3: x will raise by 1, y will raise by 0 (player walks to the right)