examples/game/lib/client.js
function onUserPlayerChange(data){

            var player = gameData.player;

            //Check if data contains different values
            if (player.get("angle") !== data.angle.toPrecision(1) || player.get("isAccelerating") !== data.isAccelerating){
                var buffer = micro.toBinary(data, "PlayerUpdate");
                socket.send(buffer);

                //Allow for latency before setting these changes on the player
                setTimeout(function(){
                    player.set(data);
                }, latency);
            }
        }
function onUserPlayerChange(data){

            var player = gameData.player;

            //Check if data contains different values
            if (player.get("angle") !== data.angle.toPrecision(1) || player.get("isAccelerating") !== data.isAccelerating){
                var buffer = micro.toBinary(data, "PlayerUpdate");
                socket.send(buffer);

                //Allow for latency before setting these changes on the player
                setTimeout(function(){
                    player.set(data);
                }, latency);
            }
        }
function onUserPlayerChange ( data ) { var player = gameData . player ; //Check if data contains different values if ( player . get ( "angle" ) !== data . angle . toPrecision ( 1 ) || player . get ( "isAccelerating" ) !== data . isAccelerating ) { var buffer = micro . toBinary ( data , "PlayerUpdate" ) ; socket . send ( buffer ) ; //Allow for latency before setting these changes on the player setTimeout ( function ( ) { player . set ( data ) ; } , latency ) ; } }
When a user player change event is caught, send a "PlayerUpdate" to the server
When a user player change event is caught send a PlayerUpdate to the server