Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- socket.on('character::updatePosition', function(position) {
- var CLIENT_ID = helper.getIp(socket);
- //debug handler
- var debug = helper.DEBUG('updatePosition', function() {
- console.log(CLIENT_ID + ' updatePosition to -->');
- console.log(position);
- return true;
- });
- //
- try {
- clients[CLIENT_ID].position.x = (position.x <= PLACE_SIZE.width && position.x >= 0) ? position.x : 0;
- clients[CLIENT_ID].position.y = (position.y <= PLACE_SIZE.height && position.y >= 0) ? position.y : 0;
- socket.broadcast.json.emit('character::updateClientPosition', clients);
- debug(true);
- } catch(e) {
- debug(false);
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement