/// <summary> /// Create holes on the board texture /// </summary> /// <param name="gd"></param> /// <param name="sb"></param> private void DrawHoles(GraphicsDevice gd, SpriteBatch sb) { // The length of each tile, on the X and Y axis float deltaX = width / ColNum; float deltaY = height / RowNum; int radius = circleRadius; // Calculate the distance between the leftmost point on the circle to the left wall of the tile float seperationX = (deltaX - 2 * circleRadius) / 2; float seperationY = (deltaY - 2 * circleRadius) / 2; Texture2D circle = ShapeCreator.Circle(gd, Color.White, radius); for (float x = seperationX; x < width; x += deltaX) { for (float y = deltaY + seperationY; y < height; y += deltaY) { sb.Draw(circle, new Vector2(x, y), Color.White); } } }
public Vector3[] GetCircleOfPoints(Vector2 center, int amount = 1, float radius = 1f, float rotOffset = 0f) { //clamp to 0 and 1 center.x = Mathf.Clamp(center.x, 0.01f, 0.99f); center.y = Mathf.Clamp(center.y, 0.01f, 0.99f); //get center point Vector3 c = GetPointFromLengthWidth(center.x, center.y); //get points in shape Vector3[] points = ShapeCreator.Circle(amount, radius, Vector3.forward, Vector3.up, rotOffset); for (int i = 0; i < points.Length; i++) { //if center point plus point offset is out of grid set point to center //which is already checked to be in grid points[i] = CalcPointInGrid(points[i] + c) ? points[i] + c : c; } return(points); }
/// <summary> /// Create a physical moving circle for the Four in a Row game /// </summary> /// <param name="Location"></param> /// <param name="color"></param> /// <param name="gd"></param> /// <param name="radius"></param> public CircleObject(Vector2 Location, Color color, GraphicsDevice gd, int radius) : base(Location, ShapeCreator.Circle(gd, color, radius)) { Frozen = false; }