mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-07-13 00:50:08 +08:00
Jazzing up the example
This commit is contained in:
@@ -5,25 +5,31 @@ $(function () {
|
||||
var canvas = document.getElementById('gameCanvas'), ctxCanvas = canvas.getContext('2d'), keyboard = new THREEx.KeyboardState(),
|
||||
playerSize = 0, entitySize = 0;
|
||||
|
||||
window.addEventListener('resize', resizeCanvas, false);
|
||||
|
||||
GarageServerIO.initializeGarageServer('http://garageserver_io.jbillmann.c9.io', {
|
||||
logging: true,
|
||||
onReady: startGame,
|
||||
onUpdatePlayerPrediction: GamePhysics.getNewPlayerState,
|
||||
onInterpolation: GamePhysics.getInterpolatedState,
|
||||
onWorldState: function (state) {
|
||||
document.getElementById('gameCanvas').style.width = state.width + 'px';
|
||||
document.getElementById('gameCanvas').style.height = state.height + 'px';
|
||||
playerSize = state.playerSize;
|
||||
entitySize = state.entitySize;
|
||||
}
|
||||
});
|
||||
|
||||
function resizeCanvas() {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
}
|
||||
|
||||
resizeCanvas();
|
||||
function startGame() {
|
||||
GameLoop.start(
|
||||
//Render Loop
|
||||
function () {
|
||||
ctxCanvas.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
ctxCanvas.fillStyle = 'white';
|
||||
var playerStates = GarageServerIO.getPlayerStates(),
|
||||
entityStates = GarageServerIO.getEntityStates();
|
||||
playerStates.forEach(function (player) {
|
||||
|
||||
Reference in New Issue
Block a user