void RotateFigure() { int oldConfig = figure.config; //Clockwise figure.config = (figure.config + 1) % 4; figure.CreateShape(); bool pass = !IsWrongPlace(); if (!pass) { //Counterclockwise figure.config = (figure.config + 2) % 4; // figure.config + 4 - 2 => prevent negative result figure.CreateShape(); pass = !IsWrongPlace(); } if (!pass) { figure.config = oldConfig; figure.CreateShape(); } }