Skip to content

Instantly share code, notes, and snippets.

@CodeDraken
Last active December 11, 2019 21:43
Show Gist options
  • Save CodeDraken/f75420c8abe3c37fff08291e558c8877 to your computer and use it in GitHub Desktop.
Save CodeDraken/f75420c8abe3c37fff08291e558c8877 to your computer and use it in GitHub Desktop.
// properties and initial velocity
const defaultProps = {
bounce: 0.75,
radius: 30,
color: 'red',
// starting velocity
startVelX: (Math.random() * 15 + 5) * (Math.floor(Math.random() * 2) || -1),
startVelY: (Math.random() * 15 + 5) * (Math.floor(Math.random() * 2) || -1)
}
export class Ball {
constructor (x = 0, y = 0, sceneProps, props) {
this.props = {
...defaultProps,
...props
}
this.sceneProps = sceneProps
this.x = x
this.y = y
this.velX = this.props.startVelX
this.velY = this.props.startVelY
}
draw (ctx) {
}
update () {
}
}
export default Ball
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment