public class BlueBallRing { public Vector2D Pos; //The actual position of the barier private float Orient; //Orientation of the whole thing public int maxBalls; //Number of balls in the total ring (counting any that have been launched) public int BallsRemaining; //When this equals 0, we're empty public float outer_rad; //radius around which the balls rotate public float ball_radius; //Radii of the balls themselves - if we switch to other reps // triangles, etc, this is where we can add extra public Vector2D[] points; //These are the effective center points of the balls public Vector2D[] StartPoints; //The precalculated starting points of the balls public boolean[] ActiveFlags; //parallel to "points," this tells us whether the balls are active or not private float thetaSep; BlueBallRing() { //Basic default values maxBalls = 30; BallsRemaining = maxBalls; Orient = 0.0f; //Facing right Pos = new Vector2D(300.0f,300.0f); outer_rad = 275.0f; ball_radius = 5.0f; //ok, so loop through the sucker, calculating where the points are. float twopi = 6.283185307f; thetaSep = twopi/maxBalls; points = new Vector2D[maxBalls]; StartPoints = new Vector2D[maxBalls]; ActiveFlags = new boolean[maxBalls]; //Initialization - Kinda slow for (int i=0; i twopi) { Orient -= twopi; } while (Orient <= 0) { Orient += twopi; } //probably need to normalize to between 2Pi and Negative 2pi or something like that here //Calculate basis vectors for the rotated coordinate frame Vector2D xPrime = new Vector2D(Math.cos(Orient), Math.sin(Orient)); Vector2D yPrime = new Vector2D(-xPrime.y, xPrime.x); //Quick Rotation of 90 degs Vector2D temp = new Vector2D(0.0f, 0.0f); for (int i=0; i