Skip to content

Instantly share code, notes, and snippets.

@JamesHagerman
Last active August 29, 2015 14:03
Show Gist options
  • Save JamesHagerman/183587fe3d4fa449840b to your computer and use it in GitHub Desktop.
Save JamesHagerman/183587fe3d4fa449840b to your computer and use it in GitHub Desktop.
A basic JS app boilerplate
// A Simple namespace
var App = (function () {
return {
ctx: null,
theTime: null,
init: function () {
console.log("init");
this.setupCanvas();
this.load();
},
load: function () {
console.log("load");
setInterval(this.update, 100);
},
update: function() {
//console.log(".");
},
draw: function() {
},
setupCanvas: function() {
this.ctx = $('#theCanvas')[0].getContext('2d');
}
};
})();
// A Simple Object
function SomeObject() {
// constructor
}
SomeObject.prototype = {
// methods and instance variables
};
// Entry point
$(document).ready(function () {
console.log("running...");
App.init();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment