function platformDetect() { var pTop, pBottom, pLeft, pRight, cTop, cBottom, cLeft, cRight; if (xmov==0 && ymov==0) return; collTime=1; for (i=0;i= pTop) && (cTop <= pBottom) && (cRight >= pLeft) && (cLeft <+ pRight)) { // now find which side we hit. // check top if (cBottom-ymov<=pTop) { if (ymov>0) { var tmp = (pTop-cBottom+ymov)/ymov; if (tmp<=collTime) { collTime=tmp; hitClip = "squashBottom"; } } else onSurface=true; } // check bottom else if (cTop-ymov>=pBottom && ymov<0) { var tmp = (pBottom-cTop+ymov)/ymov; if (tmp < collTime) { collTime=tmp; hitClip = "squashTop"; } } // check left of platform if (cRight-xmov<=pLeft && xmov>0) { //hit the left side of the platform var tmp = (pLeft - cRight + xmov)/xmov; if (tmp < collTime) { collTime = tmp; hitClip = "squashRight"; } } else if (cLeft-xmov >= pRight && xmov < 0) { // hit the right side of the platfrom var tmp = (pRight - cLeft + xmov)/xmov; if (tmp < collTime) { collTime=tmp; hitClip="squashLeft"; } } } } }