//A simple class which is very much like a ball, except controlled // directly by the players public class Paddle { public float r; //Radius public int rVal,gVal,bVal,rValOrig,gValOrig,bValOrig; //Color Values public boolean blueSwitch; //Am I currently activated? public boolean bsPrevFrame; //Was I activated last frame? public boolean FiredThisFrame; //So that we only fire once when tested //To use the paddle class, you need to use Get and Set methods, since they hide // physics logic private Vector2D Pos; private Vector2D Vel; //This will need to be calculated each frame Paddle() { Pos = new Vector2D(); Vel = new Vector2D(); r = 20.0f; blueSwitch = false; bsPrevFrame = false; FiredThisFrame = false; //rVal = 0; //gVal = 0; //bVal = 0; } public void SetPosition(float x, float y, float delta_t) //be sure to run this function whenever changing paddle position { //Uses a simple Verlet scheme to determine the velocity of the paddle from two positions Vector2D dPos = new Vector2D(x-Pos.x, y-Pos.y); Pos.Set(x,y); if (delta_t != 0.0f) Vel.Set(dPos.Times(1/delta_t)); else Vel.Set(0,0); //We're basically undefined over an empty time period anyhow } //returns a copy of the Position vector public Vector2D GetPosition() { return new Vector2D(Pos); } //Returns a copy of the current Velocity Vector public Vector2D GetVelocity() { return new Vector2D(Vel); } }