Advertisement
Guest User

Untitled

a guest
Mar 24th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. socket.on('character::updatePosition', function(position) {
  2. var CLIENT_ID = helper.getIp(socket);
  3. //debug handler
  4. var debug = helper.DEBUG('updatePosition', function() {
  5. console.log(CLIENT_ID + ' updatePosition to -->');
  6. console.log(position);
  7. return true;
  8. });
  9. //
  10. try {
  11. clients[CLIENT_ID].position.x = (position.x <= PLACE_SIZE.width && position.x >= 0) ? position.x : 0;
  12. clients[CLIENT_ID].position.y = (position.y <= PLACE_SIZE.height && position.y >= 0) ? position.y : 0;
  13. socket.broadcast.json.emit('character::updateClientPosition', clients);
  14. debug(true);
  15. } catch(e) {
  16. debug(false);
  17. };
  18. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement