edu.trinity.cs.gamecore.basic
Class BasicBlock

java.lang.Object
  extended by edu.trinity.cs.gamecore.basic.BasicBlock
All Implemented Interfaces:
Block<BasicBlock,BasicEntity>, java.io.Serializable
Direct Known Subclasses:
BasicBlock1

public class BasicBlock
extends java.lang.Object
implements Block<BasicBlock,BasicEntity>

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
See Also:
Serialized Form

Constructor Summary
BasicBlock()
           
 
Method Summary
 java.awt.Container getEditPropertiesPanel()
          This method returns a panel that should be set up so that users can edit the properties of this block.
 java.awt.Image getImage()
          This returns the image that should be drawn for this block.
 Location<BasicBlock,BasicEntity> getLinkLocation()
          Returns the location that this block links to.
 void setLinkLocation(Location<BasicBlock,BasicEntity> linkLocation)
          Sets the location that this block links to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicBlock

public BasicBlock()
Method Detail

getImage

public java.awt.Image getImage()
Description copied from interface: Block
This returns the image that should be drawn for this block. What is returned will be scaled to the size of one block for drawing. Note that blocks will not properly display animations.

Specified by:
getImage in interface Block<BasicBlock,BasicEntity>
Returns:
The image that is to be drawn for this block.

getEditPropertiesPanel

public java.awt.Container getEditPropertiesPanel()
Description copied from interface: Block
This method returns a panel that should be set up so that users can edit the properties of this block. Block properties can be used to reduce the number of block types that you create if you have many blocks in your game that server very similar functions. The returned value can be any java.awt.Container though I recommend that you use javax.swing.JPanel. The properties for blocks don't have to include link locations because the screen editor handles those in another way.

Specified by:
getEditPropertiesPanel in interface Block<BasicBlock,BasicEntity>
Returns:
A Container with a GUI set up for editing properties. If there are no editable properties it should return null.

getLinkLocation

public Location<BasicBlock,BasicEntity> getLinkLocation()
Description copied from interface: Block
Returns the location that this block links to. When an entity that follows links moves onto a block with a link it will be "transported" to that location. If a given type of block should never have a link from it, this can simply return null.

Specified by:
getLinkLocation in interface Block<BasicBlock,BasicEntity>
Returns:
The location this block links to or null if no link.

setLinkLocation

public void setLinkLocation(Location<BasicBlock,BasicEntity> linkLocation)
Description copied from interface: Block
Sets the location that this block links to. Some blocks can ignore this if they don't support linking.

Specified by:
setLinkLocation in interface Block<BasicBlock,BasicEntity>
Parameters:
linkLocation - The location the block should link to.