Skip to content

Instantly share code, notes, and snippets.

@seeruk
Created October 17, 2014 09:00
Show Gist options
  • Save seeruk/9b558ac658514dd35fd7 to your computer and use it in GitHub Desktop.
Save seeruk/9b558ac658514dd35fd7 to your computer and use it in GitHub Desktop.
var BreakOut = (function() {
"use strict";
var defaults {
ball: {
position: {
x: 200,
y: 200
},
velocity: {
x: 18,
y: 10
}
},
canvas: {
height: 600,
width: 600,
}
};
var ball = {
position: {
x: defaults.ball.position.x,
y: defaults.ball.position.y
},
velocity: {
x: defaults.ball.velocity.x,
y: defaults.ball.velocity.y
}
};
return {
collide: function() {
if (ball.position.y + ball.velocity.y <= 0) {
ball.velocity.y = -ball.velocity.y;
}
// ... so on, so on
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment