Game Development Reference
In-Depth Information
cam.dir=vec3.fromValues(parseInt(messageObj.message.
dir[0]),parseInt(messageObj.message.dir[1]),
parseInt(messageObj.message.dir[2]));
cam.pos=vec3.fromValues(
parseInt(messageObj.message.position[0]),
parseInt(messageObj.message.position[1]),
parseInt(messageObj.message.position[2]));
break;
case "grenade":
leftHand.visible=true;
break;
case "bullet":
bullets[parseInt(messageObj.message.bulletIndex)].
initialize();
break;
}
}else{
console.log(messageObj.message.type);
}catch(e){
console.log(e);
}
console.log(message);
}
The following sendRoomMessage function is invoked from different sections of our
application, whenever we want to update the game state:
function sendRoomMessage(message){
socket.emit('clientMessage', message);
}
</script>
Now, let's look at other modifications in the code to update the game state.
The first modification is in the start function. The start function assigns a
cameraChangedCallBack handler function in keyboardInteractor . The following
callback function is invoked when the camera location is changed:
function start() {
...
keyboardInteractor.cameraChangedCallBack=cameraLocationChanged;
...
}
 
Search WWH ::




Custom Search