Advertisement
Guest User

Particle.java

a guest
Oct 28th, 2012
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.80 KB | None | 0 0
  1. package genericzombieshooter.structures;
  2.  
  3. import java.awt.Point;
  4. import java.awt.geom.AffineTransform;
  5. import java.awt.geom.Rectangle2D;
  6. import java.awt.image.BufferedImage;
  7. import java.io.File;
  8. import java.io.IOException;
  9. import javax.imageio.ImageIO;
  10.  
  11. /**
  12.  *
  13.  * @author packetpirate
  14.  */
  15. public class Particle extends Rectangle2D.Double {
  16.     // Member variables.
  17.     private Point target;
  18.     private AffineTransform af;
  19.     private BufferedImage img;
  20.    
  21.     public Particle() {
  22.         super();
  23.         target = new Point();
  24.         af = new AffineTransform();
  25.         img = null;
  26.     }
  27.     public Particle(double x_, double y_, double w_, double h_) {
  28.         super(x_, y_, w_, h_);
  29.         target = new Point();
  30.         af = new AffineTransform();
  31.         img = null;
  32.     }
  33.     public Particle(double x_, double y_, double w_, double h_, Point target_) {
  34.         super(x_, y_, w_, h_);
  35.         target = target_;
  36.         af = new AffineTransform();
  37.         img = null;
  38.     }
  39.     public Particle(double x_, double y_, double w_, double h_, Point target_, String fileName_) {
  40.         super(x_, y_, w_, h_);
  41.         target = target_;
  42.         af = new AffineTransform();
  43.         LoadImage(fileName_);
  44.     }
  45.     private void LoadImage(String fileName_) {
  46.         try {
  47.             img = ImageIO.read(new File(fileName_));
  48.         } catch(IOException io) {
  49.             System.out.println("File not found!");
  50.         }
  51.     }
  52.    
  53.     public Point getTarget() { return target; }
  54.     public void setTarget(Point target_) { target = target_; }
  55.     public AffineTransform getTransform() { return af; }
  56.     public BufferedImage getImage() { return img; }
  57.    
  58.     // Shape manipulation.
  59.     public void rotate(double theta_, double cx_, double cy_) { af.setToRotation(theta_, cx_, cy_); }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement