home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 07 DecisionMaking Architectures / 01 Isla, Blumberg / DrawableObject.java < prev    next >
Encoding:
Java Source  |  2001-09-25  |  817 b   |  36 lines

  1. package bb;
  2.  
  3. import java.awt.*;
  4. import java.awt.geom.*;
  5.  
  6. /*
  7. The abstract base class for all objects that can be drawn, whether they are
  8. agents or resource pools or whatever.
  9.  
  10. @author naimad
  11. */
  12.  
  13. public abstract class DrawableObject {
  14.     
  15.     Shape drawShape = null;
  16.     Vec2 pos = new Vec2();
  17.     
  18.     public DrawableObject(Vec2 pos) {
  19.         this.pos.set(pos);
  20.         drawShape = createShape();
  21.     }
  22.     
  23.     AffineTransform trans = new AffineTransform();
  24.     public void updateGraphics(double time, Graphics2D g2) {
  25.         g2.translate(pos.x(), pos.y());
  26.         drawShape(time, g2);
  27.         g2.translate(-pos.x(), -pos.y());
  28.     }
  29.     
  30.     public void drawShape(double time, Graphics2D g2) {
  31.         g2.fill(drawShape);
  32.     }
  33.     
  34.     public abstract Shape createShape();
  35.     
  36. }