Created
March 1, 2014 22:32
-
-
Save dpogorzelski/9298522 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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