function Bubble(x, y, direction, canvas){
  this.x = x;
  this.y = y;
  this.direction = direction;
  this.status = "new";
  this.height = 30;
  this.width = 30;
  this.count = 0;
  this.canvas = canvas;
  this.image = setBubbleImage('images/bubble_new.png');
  setXAndXInc(this);
}

Bubble.prototype.draw = function(context) {
  context.drawImage(this.image, this.x, this.y, this.width, this.height);
  return this;
};

Bubble.prototype.move = function() {
  var bubble = this;
  float(bubble);
  bubble.count++;
  if (doneFloatingSidewaysOrHitAWall(bubble)) {
    bubble.status = "floating";
    if (!bubble.filled) {
      bubble.image = setBubbleImage('images/bubble_floating.png');
    }
  }
  if (onRightEdge(bubble)) {
    bubble.x = bubble.canvas.width - bubble.width;
  }
  if (onLeftEdge(bubble)) {
    bubble.x = 0;
  }
  if (onCeiling(bubble)) {
    bubble.status = "done";
  }
  return bubble;
};

Bubble.prototype.fillUp = function() {
  this.status = "floating";
  this.image = setBubbleImage('images/bubble_filled.png');
  this.filled = true;
};

function doneFloatingSidewaysOrHitAWall(bubble) {
  return onRightEdge(bubble) || onLeftEdge(bubble) || bubble.count === 100;
}

function onCeiling(bubble) {
  return bubble.y <= 0;
}

function onRightEdge(bubble) {
  return bubble.x >= bubble.canvas.width - bubble.width;
}

function onLeftEdge(bubble) {
   return bubble.x <= 0;
}

function float(bubble) {
  if (bubble.status === "new") {
    bubble.x += bubble.xInc;
  } else if (bubble.status === "floating") {
    bubble.y--;
  }
  return bubble;
}


function setXAndXInc(bubble) {
  if (bubble.direction === "right") {
    bubble.x += 3;
    bubble.xInc = 1;
  } else {
    bubble.x -= 3;
    bubble.xInc = -1;
  }
}

function setBubbleImage(imageSrc) {
  var image = document.createElement("img");
  image.src = imageSrc;
  image.style.visibility = 'hidden';
  return image;
}
module.exports = Bubble;

@@ -253,16 +253,37 @@
 .png');%0A
+  this.drift = 0.25;%0A
   setXAn
@@ -868,38 +868,56 @@
 (bubble)) %7B%0A    
-bubble
+driftX(bubble);%0A    this
 .status = %22done%22
@@ -1091,20 +1091,281 @@
 = true;%0A
-
 %7D;%0A%0A
+function driftX(bubble) %7B%0A  if (Math.random() %3C 0.10) %7B bubble.drift *= -1; %7D%0A  if ((bubble.drift %3C 0 && bubble.x %3E -1*bubble.drift) %7C%7C%0A      (bubble.drift %3E 0 && bubble.x %3C bubble.canvas.width-bubble.width-bubble.drift)) %7B%0A    bubble.x += bubble.drift;%0A  %7D%0A%7D%0A%0A
 function

Add random drift for bubbles on the ceiling