001 package components; 002 003 import java.util.Map; 004 005 import physics3d.Angle; 006 import physics3d.GameConstants; 007 import physics3d.Vect3; 008 009 /** 010 * <p> 011 * A LeftFlipper extends Flipper, and flips in the left direction. 012 * </p> 013 * 014 * A LeftFlipper has no unique properties that its parent does not have. The only stipulation is that 015 * it has a negative Z_HAT Orientation Vector, as opposed to the positive Z_HAT Orientation Vector found 016 * in a RightFlipper. 017 * 018 */ 019 020 public class LeftFlipper extends Flipper { 021 022 023 public LeftFlipper(Map<String, String> props, GameSpace gs) { 024 super(props, gs); 025 //left flips have different orientation and angle 026 this.setOrientVect(Vect3.Z_HAT.neg()); 027 this.setOrientAngle(Angle.ZERO.minus(orientAngle)); 028 } 029 030 /** for flippers, diff depends on orientation **/ 031 @Override 032 public Vect3 getDiff() { 033 double r = GameConstants.FLIPPER_RADIUS_FRACTION; 034 int oa = (int)orientAngle.degrees(); 035 if (oa == 0) { 036 return new Vect3(r, r, 0.5); 037 } else if (oa == 90) { 038 return (new Vect3(r, r, 0.5)); 039 } else if (oa == 180) { 040 return (new Vect3(2-r, 2-r, 0.5)); 041 } else if (oa == -90) { 042 return (new Vect3(2-r, 2-r, 0.5)); 043 } else { 044 throw new IllegalArgumentException("orientAngle must be 0, 90, 180, or 270 degrees, it is " + orientAngle.degrees()); 045 } 046 } 047 048 //See super class 049 public void getBasicPropertyMap(Map<String,String> m) { 050 if (this.orientAngle.degrees() == -90) { 051 m.put("orientation", "270"); 052 } else { 053 m.put("orientation", Integer.toString((int)Math.round(this.orientAngle.degrees()))); 054 } 055 super.getBasicPropertyMap(m); 056 } 057 058 public GameObjectClassification getGOClassification() { 059 return GameObjectClassification.LEFTFLIPPER; 060 } 061 }