Skip to content

Instantly share code, notes, and snippets.

@ashimaathri
Last active August 29, 2015 14:14
Show Gist options
  • Save ashimaathri/961822c4a6aa8da05cf4 to your computer and use it in GitHub Desktop.
Save ashimaathri/961822c4a6aa8da05cf4 to your computer and use it in GitHub Desktop.
Step 2 of VTHacks Angry Bird Tutorial
var game, createRenderer;
createRenderer = function (width, height) {
return Physics.renderer('canvas', {
el: 'my-game',
width: width,
height: height,
meta: false,
autoResize: false,
styles: {
'rectangle': {
strokeStyle: '#000000',
lineWidth: 1,
fillStyle: '#000000'
}
}
});
};
game = function (world) {
var screenWidth, screenHeight;
// Get the dimensions of the screen
screenWidth = window.innerWidth;
screenHeight = window.innerHeight/2;
// Setup the rendering process
world.add(createRenderer(screenWidth, screenHeight));
// On every step of the world, render the new state of the world
world.on('step', function () {
world.render();
});
};
Physics(game);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment