private void changingFaceControl(long thisTime) { float bw = Constants.BlockWidth / 2; int maxRange = 23; //Variabile per vedere quando iniziare il cambio di faccia int relX = getRelativeX(thisTime) - (int)(bw); float maxR = bw * (Constants.JumpableBlockRatio * 4); //Questo serve per allineare a 16 e 48 pt double d = xyrotatorAnim.GetAnimation(0).GetCurrentSpeed(thisTime); if (d > 0 && relX > maxRange && game.CheckBlocks(false) != 0) { //TODO: Sono a destra e vado a destra float offset = -relX + maxR; Matrix m = new Matrix(); m.Rotate(-rot); PointF off = m.TransformPointF(new PointF(offset, 0)); xyrotatorAnim.ChangeAnimator( 0, new SteadyAnimator( Math.Round(centerX + off.X), thisTime) ); xyrotatorAnim.ChangeAnimator( 1, new SteadyAnimator( Math.Round(centerY + off.Y), thisTime) ); int block = game.CheckBlocks(false); changeFace(false, block, offset, thisTime); } else if (d < 0 && relX < -maxRange && game.CheckBlocks(true) != 0) { //TODO: Sono a sinistra e vado a sinistra float offset = -relX - maxR; Console.WriteLine("E qui? Relative X =" + relX + "; MaxR = " + maxR + "=> offset = " + offset); Matrix m = new Matrix(); m.Rotate(-this.rot); PointF off = m.TransformAndThenRound(new PointF(offset, 0)); xyrotatorAnim.ChangeAnimator( 0, new SteadyAnimator( Math.Round(centerX + off.X), thisTime) ); xyrotatorAnim.ChangeAnimator( 1, new SteadyAnimator( Math.Round(centerY + off.Y), thisTime) ); if (relX == -32) { Console.WriteLine("Caso anomalo: Relative X =" + relX + "; MaxR = " + maxR + "=> offset = " + offset); Console.WriteLine("Per evitare di finire dentro un blocco (problemini numerici...), sposto la palla indietro"); bugRecovery(relX); } int block = game.CheckBlocks(true); changeFace(true, block, offset, thisTime); } }