package edu.trinity.cs.gamecore.basic;
import java.awt.image.*;
import java.awt.*;
import edu.trinity.cs.gamecore.Block;
import edu.trinity.cs.gamecore.Location;
/**
*
This is a basic implementation of the Block interface. Starting with assignment 2
* you will create your own implementations of Block and this won't be used. Notice the
* generic structure.
*
* The Image is static because all the blocks share the same image. If you have different
* images for your blocks then this shouldn't be static. The Image is transient because
* images can't be saved through serialization which will cause problems if you use the
* ScreenEditor.
*
* @author Mark Lewis
*/
public class BasicBlock implements Block {
public BasicBlock() {
}
public Image getImage(){
if(img==null) {
img=new BufferedImage(30,30,BufferedImage.TYPE_INT_RGB);
Graphics g=img.getGraphics();
g.setColor(Color.lightGray);
g.fillRect(0,0,30,30);
g.setColor(Color.red);
g.fillRect(0,0,10,10);
}
return img;
}
public Container getEditPropertiesPanel(){ return null; }
public Location getLinkLocation(){ return link; }
public void setLinkLocation(Location linkLocation){
link=linkLocation;
}
private Location link = null;
/** As noted above:
*
* The Image is static because all the blocks share the same image. If you
* have different images for your blocks then this shouldn't be static.
* Image is transient because images can't be saved through serialization
* which will cause problems if you use the ScreenEditor.
*/
private static transient Image img=null;
/** To make serialization work well (which is needed if you use the
* ScreenEditor), every class you write should have a variable
* serialVersionUID defined like this one. The exact value is not
* important; all that's important is that it be different for
* every class you write.
*/
private static final long serialVersionUID=457609283376092346l;
}