Created
October 17, 2014 09:00
-
-
Save seeruk/9b558ac658514dd35fd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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