Skip to content

Instantly share code, notes, and snippets.

@rob-murray
Created December 14, 2012 16:05
Show Gist options
  • Save rob-murray/4286523 to your computer and use it in GitHub Desktop.
Save rob-murray/4286523 to your computer and use it in GitHub Desktop.
(function() {
// create global namespace
window.game = {};
// add some data
game.player = {
name: 'rob',
score: 5
};
game.enemies = [];
game.enemies.push({
name: "zombie",
hp: 10
});
game.alertMe = function(player){
alert(player.name);
};
}());
(function(player) {
// set up the UI
alert(player.name);
alert(player.score);
game.alertMe(player);
}(game.player));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment