Modified perpixel.js to solve collision bug