MDN self-hosted library · e01.org

Randomizing gameplay

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
class Paddle extends GameObject {
  // …
  onCollide() {
    ball.playWobble();
    ball.vel.x = -5 * (this.pos.x - ball.pos.x);
  }
}