Skip to content

Instantly share code, notes, and snippets.

@dpogorzelski
Created March 1, 2014 22:32
Show Gist options
  • Save dpogorzelski/9298522 to your computer and use it in GitHub Desktop.
Save dpogorzelski/9298522 to your computer and use it in GitHub Desktop.
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
player.animations.play('left');
player.x -= 3;
var pos = JSON.stringify({
x: player.x
});
sock.send(pos);
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
player.animations.play('right');
player.x += 3;
var pos = JSON.stringify({
x: player.x
});
sock.send(pos);
} else if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
player.animations.play('up');
player.y -= 3;
var pos = JSON.stringify({
y: player.y
});
sock.send(pos);
} else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
player.animations.play('down');
player.y += 3;
var pos = JSON.stringify({
y: player.y
});
sock.send(pos);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment