(function () {
  'use strict';

  function Entity(x, y, width, height, spriteSrc, framesPosition, frameCooldown, speed, renderedWidth, renderedHeight) {
    this.init(x, y, width, height, spriteSrc, framesPosition, frameCooldown, speed, renderedWidth, renderedHeight);
  }

  Entity.prototype.init = function (x, y, width, height, spriteSrc, framesPosition, frameCooldown, speed, renderedWidth, renderedHeight) {
    this.x = x;
    this.y = y;

    this.constructor.width = width;
    this.constructor.height = height;

    this.constructor.renderedWidth = renderedWidth ? renderedWidth : width;
    this.constructor.renderedHeight = renderedHeight ? renderedHeight : height;

    this.constructor.spriteSrc = spriteSrc;
    this.constructor.framesPosition = this.constructor.framesPosition || framesPosition;
    this.constructor.frameCooldown = frameCooldown;
    this.lastFrameUpdate = Date.now();
    this.currentFrame = 0;
    if (spriteSrc) {
      this.loadSprite();
    }

    // Speed is defined as pixels per second
    this.speed = speed || 200;
  };

  Entity.prototype.loadSprite = function () {
    if (this.constructor.spriteLoaded) {
      return;
    }

    var self = this;

    this.constructor.spriteLoaded = false;
    this.constructor.sprite = new Image();

    this.constructor.sprite.src = this.constructor.spriteSrc;
    this.constructor.sprite.onload = function () {
      self.constructor.spriteLoaded = true;
    };
  };

  Entity.prototype.setPosition = function (x, y) {
    this.setX(x);
    this.setY(y);
  };

  Entity.prototype.setX = function (x) {
    this.x = x;
  };

  Entity.prototype.setY = function (y) {
    this.y = y;
  };

  Entity.prototype.render = function (context) {
    if (this.constructor.spriteLoaded) {
      context.drawImage(
        this.constructor.sprite,
        this.constructor.framesPosition[this.currentFrame][0],
        this.constructor.framesPosition[this.currentFrame][1],
        this.constructor.width,
        this.constructor.height,
        this.x,
        this.y,
        this.constructor.renderedWidth,
        this.constructor.renderedHeight);
    }
  };

  Entity.prototype.update = function (now) {
    now = now || Date.now();

    if (now - this.lastFrameUpdate > this.constructor.frameCooldown) {
      this.currentFrame += 1;
      this.lastFrameUpdate = now;
      if (this.constructor.framesPosition.length <= this.currentFrame) {
        this.currentFrame = 0;
      }
    }
  };

  Entity.prototype.isCollided = function (entity2) {
    // no collision if there's any gap
    return !(this.x + this.constructor.renderedWidth <= entity2.x ||
      this.x > entity2.x + entity2.constructor.renderedWidth         ||
      this.y + this.constructor.renderedHeight <= entity2.y       ||
      this.y > entity2.y + entity2.constructor.renderedHeight
    );
  };

  // Make Entity available globally
  window.Entity = Entity;

}());

@@ -2454,32 +2454,232 @@
   %7D%0A    %7D%0A  %7D;%0A%0A
+  // allow a little bit of proximity between entities before considering%0A  // a collision, it improves the experience, otherwise some%0A  // entities collide before it was expected%0A  Entity.adjust = 5;%0A
   Entity.prototy
@@ -2807,16 +2807,32 @@
 edWidth 
+- Entity.adjust 
 %3C= entit
@@ -2900,18 +2900,31 @@
 edWidth 
-  
+- Entity.adjust
       %7C%7C
@@ -2971,16 +2971,32 @@
 dHeight 
+- Entity.adjust 
 %3C= entit
@@ -3070,16 +3070,32 @@
 edHeight
+ - Entity.adjust
 %0A    );%0A

Allow a 5 pixels of proximity between entities before collision