(function() {
  "use strict";
  let canvas = document.getElementById("canvas");
  let context = canvas.getContext("2d");
  let lastUpdate = 0;
  let particles = [];
  const COLOURS = ['white', 'green', 'yellow', 'orange', 'pink', 'blue', 'brown', 'red', 'magenta', 'purple'];
  const GRAVITY = 2;

  window.addEventListener("resize", resizeCanvas);
  canvas.addEventListener("click", addParticle);

  function resizeCanvas(oEvent) {
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
    draw();
  }

  function addParticle(oEvent) {
    let colour = COLOURS[Math.floor(Math.random() * COLOURS.length)];
    let particle = new Particle(oEvent.clientX, oEvent.clientY, 5, colour);
    particles.push(particle);
  }

  function update(timestamp) {
    if (lastUpdate === 0) {
      lastUpdate = timestamp;
    }
    let dTime = (timestamp - lastUpdate) / 1000;

    particles.forEach(particle => particle.update(dTime));

    draw(dTime);
    lastUpdate = timestamp;
    window.requestAnimationFrame(time => update(time));
  }

  function draw(dTime) {
    context.clearRect(0, 0, canvas.width, canvas.height);

    particles.forEach(particle => particle.draw(context));
  }
  resizeCanvas();
  window.requestAnimationFrame(timestamp => update(timestamp));

  class Particle {
    constructor(x, y, size, colour) {
      this.x = x;
      this.y = y;
      this.size =  size;
      this.colour = colour;

      this.acceleration = {
        y: 0
      }
    }

    draw(context) {
      context.fillStyle = this.colour;
      context.fillRect(this.x, this.y, this.size, this.size);
    }

    update(dTime) {
      this.acceleration.y = this.acceleration.y + GRAVITY * dTime;
      this.y = this.y + this.acceleration.y;
    }
  }
})();

@@ -287,17 +287,40 @@
 AVITY = 
-2
+-7;%0A  const FRICTION = 5
 ;%0A%0A  win
@@ -720,16 +720,23 @@
 , colour
+, 5, -5
 );%0A    p
@@ -1359,16 +1359,24 @@
 , colour
+, vx, vy
 ) %7B%0A    
@@ -1476,25 +1476,36 @@
 his.
-acceleration
+velocity
  = %7B%0A
+        x: vx,%0A
     
@@ -1511,17 +1511,18 @@
      y: 
-0
+vy
 %0A      %7D
@@ -1692,63 +1692,112 @@
 his.
-acceleration.y = this.acceleration.y + GRAVITY * dTime;
+velocity.y -= GRAVITY * dTime;%0A      this.velocity.x -= Math.sign(this.velocity.x)  * dTime * FRICTION;%0A
 %0A   
@@ -1808,17 +1808,17 @@
 his.
-y
+x
  = this.
 y + 
@@ -1817,17 +1817,17 @@
 his.
-y
+x
  + this.
 acce
@@ -1826,20 +1826,57 @@
 his.
-acceleration
+velocity.x;%0A      this.y = this.y + this.velocity
 .y;%0A

Add velocity x/y