public void calcBeforeFolding(EdgePosition first, EdgePosition second) { foldLine.X = (float)((float)(second.y - (float)first.y) / ((float)second.x - (float)first.x)); perpendicular.X = -1 / foldLine.X; if (foldLine.X == 0) //fold line is horizontal { center.X = ballRec.X; center.Y = first.y; } else { if (perpendicular.X == 0) //fold line is vertical { center.X = first.x; center.Y = ballRec.Y; } else { foldLine.Y = (float)((float)first.y - (float)first.x * foldLine.X); perpendicular.Y = ballRec.Y - ballRec.X * perpendicular.X; center.X = -(foldLine.Y - perpendicular.Y) / (foldLine.X - perpendicular.X); center.Y = perpendicular.X * center.X + perpendicular.Y; } } angleBetweenPoints = (float)Math.Atan2(ballRec.Y - center.Y, ballRec.X - center.X); radius = Vector2.Distance(new Vector2(ballRec.X, ballRec.Y), new Vector2(center.X, center.Y)); //calcLT(); //calcLB(); //calcRT(); //calcRB(); }
public Board(Texture2D outT,Texture2D inT,Texture2D blank,int screenW,int screenH) { outX = outY = DISTANCEfromSCREEN; outH = screenH - 2*DISTANCEfromSCREEN; outW = screenW - 2*DISTANCEfromSCREEN; inX = inY = DISTANCEfromSCREEN+DISTANCEfromOUTER; inY1 = screenH - DISTANCEfromSCREEN - DISTANCEfromOUTER; inX1 = screenW - DISTANCEfromSCREEN - DISTANCEfromOUTER; outerTex = outT; innerTex = inT; blankTex = blank; blankTex.SetData(new[] { Color.White }); edge1 = new EdgePosition(); edge2 = new EdgePosition(); }
public void DrawFolding(SpriteBatch spriteBatch, EdgePosition first, EdgePosition second) { spriteBatch.Draw(ballTex, new Rectangle(ballAfterFolding.X, ballAfterFolding.Y,(int)(10 + 10 * Math.Sin(foldingAngle)), (int)(10 + 10 * Math.Sin(foldingAngle))), null, Color.Gold, 0, new Vector2(ballSize / 2, ballSize / 2), SpriteEffects.None, 0); #region flipping the page //if ((first.theEdge == Edge.Top) && (second.theEdge == Edge.Left)) //{ // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingLT, new Vector2(first.x + 4, first.y + 4)); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingLT, new Vector2(second.x + 4, second.y + 4)); // DrawLine(spriteBatch, 3, Color.Black, new Vector2(first.x + 4, first.y + 4), AfterFoldingRT); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingRT, AfterFoldingRB); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingRB, AfterFoldingLB); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingLB, new Vector2(second.x + 4, second.y + 4)); //} //// top -> left / left -> top //if (((first.theEdge == Edge.Top) && (second.theEdge == Edge.Left) && ((ballRec.X - ballAfterFolding.X) < 0)) // || ((second.theEdge == Edge.Top) && (first.theEdge == Edge.Left) && ((ballRec.X - ballAfterFolding.X) < 0))) //{ // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingLT, new Vector2(first.x + 4, first.y + 4)); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingLT, new Vector2(second.x + 4, second.y + 4)); //} //else //{ // // top <- left // if ((first.theEdge == Edge.Top) && (second.theEdge == Edge.Left) && ((ballRec.X - ballAfterFolding.X) > 0)) // { // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingRT, new Vector2(first.x + 4, first.y + 4)); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingLB, new Vector2(second.x + 4, second.y + 4)); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingLB, AfterFoldingRB); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingRT, AfterFoldingRB); // } // else // { // left <- top // if ((second.theEdge == Edge.Top) && (first.theEdge == Edge.Left) && ((ballRec.X - ballAfterFolding.X) > 0)) // { // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingLB, new Vector2(first.x + 4, first.y + 4)); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingRT, new Vector2(second.x + 4, second.y + 4)); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingLB, AfterFoldingRB); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingRT, AfterFoldingRB); // } // else // { // top <- right / right <- top // if (((first.theEdge == Edge.Top) && (second.theEdge == Edge.Right) && ((ballAfterFolding.X - ballRec.X) < 0)) // || ((second.theEdge == Edge.Top) && (first.theEdge == Edge.Right) && ((ballAfterFolding.X - ballRec.X) < 0))) // { // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingRT, new Vector2(first.x + 4, first.y + 4)); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingRT, new Vector2(second.x + 4, second.y + 4)); // } // else // { // top -> right // if ((first.theEdge == Edge.Top) && (second.theEdge == Edge.Right) && ((ballAfterFolding.X - ballRec.X) > 0)) // { // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingLT, new Vector2(first.x + 4, first.y + 4)); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingRB, new Vector2(second.x + 4, second.y + 4)); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingRB, AfterFoldingRB); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingLT, AfterFoldingRB); // } // else // { // right <- top // if ((second.theEdge == Edge.Top) && (first.theEdge == Edge.Right) && ((ballAfterFolding.X - ballRec.X) > 0)) // { // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingRB, new Vector2(first.x + 4, first.y + 4)); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingLT, new Vector2(second.x + 4, second.y + 4)); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingRB, AfterFoldingRB); // DrawLine(spriteBatch, 3, Color.Black, AfterFoldingLT, AfterFoldingRB); // } // } // } // } // } //} #endregion }