function actionRotate(ccw) {
  var oldRotation = currentShape.currentRotation;
  var oldCoords = currentShape.coords;
  var oldX = currentShape.currentX;
  var oldY = currentShape.currentY;
  currentShape.currentRotation += ccw ? -1 : 1;
  var rotationPoint = currentShape.shape.rotation;
  var cx = currentShape.currentX + rotationPoint[0];
  var cy = currentShape.currentY - rotationPoint[1] + 1;
  currentShape.coords = rotateCoords(currentShape.coords, ccw, cx, cy);
  if (currentShape.isCollided()) {
    // Simple rotation failed.  Try kicking the rotated shape around.
    if (!currentShape.shape.kicks) throw Error('Kicks not found.');
    var oldQuadrant = quadrant(currentShape.oldRotation);
    var newQuadrant = quadrant(currentShape.currentRotation);
    var kickList = currentShape.shape.kicks[oldQuadrant + '>' + newQuadrant];
    if (!kickList) throw Error('Matching kick not found.');
    var preKickCoords = currentShape.coords;
    var preKickX = currentShape.currentX;
    var preKickY = currentShape.currentY;
    for (var i = 0, kick; (kick = kickList[i]); i++) {
      currentShape.coords = moveCoords(currentShape.coords, kick[0], kick[1]);
      currentShape.currentX += kick[0];
      currentShape.currentY += kick[1];
      if (!currentShape.isCollided()) {
        break;
      }
      currentShape.coords = preKickCoords;
      currentShape.currentX = preKickX;
      currentShape.currentY = preKickY;
    }
    if (currentShape.isCollided()) {
      // All kicks failed.  Aborting rotation.
      currentShape.currentRotation = oldRotation;
      currentShape.coords = oldCoords;
      currentShape.currentX = oldX;
      currentShape.currentY = oldY;
    }
  }
  currentShape.addTransform(true);
  currentShape.checkSurfaced();
  printDebug();
}
// Rotate the current shape clockwise or counter-clockwise.
Rotate the current shape clockwise or counter-clockwise.
Rotate the current shape clockwise or counter - clockwise .
function actionRotate(ccw) {
  var oldRotation = currentShape.currentRotation;
  var oldCoords = currentShape.coords;
  var oldX = currentShape.currentX;
  var oldY = currentShape.currentY;
  currentShape.currentRotation += ccw ? -1 : 1;
  var rotationPoint = currentShape.shape.rotation;
  var cx = currentShape.currentX + rotationPoint[0];
  var cy = currentShape.currentY - rotationPoint[1] + 1;
  currentShape.coords = rotateCoords(currentShape.coords, ccw, cx, cy);
  if (currentShape.isCollided()) {
    if (!currentShape.shape.kicks) throw Error('Kicks not found.');
    var oldQuadrant = quadrant(currentShape.oldRotation);
    var newQuadrant = quadrant(currentShape.currentRotation);
    var kickList = currentShape.shape.kicks[oldQuadrant + '>' + newQuadrant];
    if (!kickList) throw Error('Matching kick not found.');
    var preKickCoords = currentShape.coords;
    var preKickX = currentShape.currentX;
    var preKickY = currentShape.currentY;
    for (var i = 0, kick; (kick = kickList[i]); i++) {
      currentShape.coords = moveCoords(currentShape.coords, kick[0], kick[1]);
      currentShape.currentX += kick[0];
      currentShape.currentY += kick[1];
      if (!currentShape.isCollided()) {
        break;
      }
      currentShape.coords = preKickCoords;
      currentShape.currentX = preKickX;
      currentShape.currentY = preKickY;
    }
    if (currentShape.isCollided()) {
      currentShape.currentRotation = oldRotation;
      currentShape.coords = oldCoords;
      currentShape.currentX = oldX;
      currentShape.currentY = oldY;
    }
  }
  currentShape.addTransform(true);
  currentShape.checkSurfaced();
  printDebug();
}
function actionRotate ( ccw ) { var oldRotation = currentShape . currentRotation ; var oldCoords = currentShape . coords ; var oldX = currentShape . currentX ; var oldY = currentShape . currentY ; currentShape . currentRotation += ccw ? - 1 : 1 ; var rotationPoint = currentShape . shape . rotation ; var cx = currentShape . currentX + rotationPoint [ 0 ] ; var cy = currentShape . currentY - rotationPoint [ 1 ] + 1 ; currentShape . coords = rotateCoords ( currentShape . coords , ccw , cx , cy ) ; if ( currentShape . isCollided ( ) ) { if ( ! currentShape . shape . kicks ) throw Error ( 'Kicks not found.' ) ; var oldQuadrant = quadrant ( currentShape . oldRotation ) ; var newQuadrant = quadrant ( currentShape . currentRotation ) ; var kickList = currentShape . shape . kicks [ oldQuadrant + '>' + newQuadrant ] ; if ( ! kickList ) throw Error ( 'Matching kick not found.' ) ; var preKickCoords = currentShape . coords ; var preKickX = currentShape . currentX ; var preKickY = currentShape . currentY ; for ( var i = 0 , kick ; ( kick = kickList [ i ] ) ; i ++ ) { currentShape . coords = moveCoords ( currentShape . coords , kick [ 0 ] , kick [ 1 ] ) ; currentShape . currentX += kick [ 0 ] ; currentShape . currentY += kick [ 1 ] ; if ( ! currentShape . isCollided ( ) ) { break ; } currentShape . coords = preKickCoords ; currentShape . currentX = preKickX ; currentShape . currentY = preKickY ; } if ( currentShape . isCollided ( ) ) { currentShape . currentRotation = oldRotation ; currentShape . coords = oldCoords ; currentShape . currentX = oldX ; currentShape . currentY = oldY ; } } currentShape . addTransform ( true ) ; currentShape . checkSurfaced ( ) ; printDebug ( ) ; }
Rotate the current shape clockwise or counter-clockwise.
Rotate the current shape clockwise or counter - clockwise .
// Simple rotation failed.  Try kicking the rotated shape around. // All kicks failed.  Aborting rotation.