Skip to content

Instantly share code, notes, and snippets.

@ruby0x1
Created March 27, 2012 14:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruby0x1/2216594 to your computer and use it in GitHub Desktop.
Save ruby0x1/2216594 to your computer and use it in GitHub Desktop.
Multi-player games in HTML5 : Server Side Ball Class
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