001 package physics3d;
002
003 import components.Ball;
004 import components.Flipper;
005 import components.GameObject;
006
007 public class Collision {
008 //fields
009 private Ball collisioner;
010 private GameObject collisionee; //could also be a ball
011 private PhysicsShape eeshape;
012 private double time;
013
014 /** initialise to a null collision **/
015 public Collision(Ball b) {
016 collisioner=b;
017 collisionee=null;
018 eeshape=null;
019 time=Double.POSITIVE_INFINITY;
020 }
021
022 /** get the object of the collision **/
023 public GameObject object() { return collisionee; }
024 public double time() { return time; }
025 public PhysicsShape shape() { return eeshape; }
026 public Ball ball() { return collisioner; }
027
028 /** set properties of collision **/
029 public void set(double time, GameObject g, PhysicsShape shape) {
030 this.time = time;
031 this.collisionee = g;
032 this.eeshape = shape;
033 }
034
035 public String toString() {
036 return "Collision["+collisioner+", "+collisionee+", "+eeshape+", at "+time +"]";
037 }
038 }