001 package breakout; 002 003 import java.awt.*; 004 005 /** 006 * interface BreakoutComponent is the basic element of the breakout 007 * system. BreakoutComponents are renderable objects that can 008 * be added to the game's World. 009 * 010 * @see breakout.World 011 * @see breakout.DefaultBreakoutComponent 012 * 013 * @author benmv@olin.edu 014 * @version <tt>$Id: BreakoutComponent.java,v 1.2 2004/03/26 20:39:33 gus Exp $</tt> 015 */ 016 public interface BreakoutComponent { 017 018 /** 019 * returns location of upper-left corner of component 020 * 021 * @return Point location of component's upper left corner. 022 */ 023 public Point getLocation(); 024 025 /** 026 * sets the location of upper-left corner of component 027 * 028 * @param Point location new location of component 029 */ 030 public void setLocation(Point p); 031 032 /** 033 * returns a point at the center of the component 034 * 035 * @return Point center of component 036 */ 037 public Point getCenter(); 038 039 /** 040 * returns the width and height of the bounding rectangle of 041 * the component. 042 * 043 * @return Dimension extents of the component. 044 */ 045 public Dimension getSize(); 046 047 /** 048 * returns the actual shape of the object. Used for intersection 049 * and rebound. Shape should be in world coordinates, not local 050 * coordinates (i.e. not relative to upper left corner of component) 051 * 052 * @return Shape of component 053 */ 054 public Shape getShape(); 055 056 /** 057 * destroys this component 058 */ 059 public void kill(); 060 061 /** 062 * returns dead status of component. 063 */ 064 public boolean isDead(); 065 066 067 /** 068 * sets the world the component lives in 069 */ 070 public void setWorld(World world); 071 072 /** 073 * the component has been struck by the given component 074 * 075 * @param BreakoutComponent bc the component hitting this one 076 */ 077 public void hitBy(BreakoutComponent bc); 078 079 /** 080 * renders this component to the screen. Origin of graphics 081 * has been translated to upper-left corner of component. 082 * 083 * @param Graphics g graphics to draw with 084 */ 085 public void paint(Graphics g); 086 087 /** 088 * returns true if the component is transient. 089 * 090 * @return boolean true if component is transient 091 */ 092 public boolean isTransient(); 093 } 094