Skip to content

Instantly share code, notes, and snippets.

@pjnovas
Created November 3, 2012 18:10
Show Gist options
  • Save pjnovas/4008161 to your computer and use it in GitHub Desktop.
Save pjnovas/4008161 to your computer and use it in GitHub Desktop.
Share Scene logic client & server side
var isClient = (typeof global === "undefined") ? true : false;
(function(arkanoid) {
var arkanoid = arkanoid || {};
if (!isClient){
arkanoid.Ball = require('./Ball.js');
arkanoid.Padd = require('./Padd.js');
}
var Scene = function() {
this.ball = new arkanoid.Ball();
this.padd = new arkanoid.Padd();
};
Scene.prototype.update = function() {
this.ball.update();
this.padd.update();
};
Scene.prototype.draw = function() {
this.ball.draw();
this.padd.draw();
};
arkanoid.Scene = Scene;
})(isClient ? window.arkanoid : exports);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment