Created
March 27, 2012 14:56
-
-
Save ruby0x1/2216594 to your computer and use it in GitHub Desktop.
Multi-player games in HTML5 : Server Side Ball Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Ball = Class.extend({ | |
init : function( attachTo, isServer ) { | |
//Only create meshes on the client side | |
if( !isServer ) { | |
//Create meshes | |
this.setupBall( ); | |
} else { | |
//Server side simulation only cares about position of the ball. | |
this.ball = { | |
position : { | |
x : 0, | |
y : 0 | |
} //position | |
} //ball | |
} //isServer | |
//Store the speed value | |
this.speed = 100; | |
//Attach if requested to | |
if(attachTo) { | |
this.attachToPlayer( attachTo ); | |
} | |
}, | |
.... | |
}); //Ball class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment