Interface Screen

All Known Implementing Classes:
BasicScreen

public interface Screen
extends Serializable

This class represents a single "screen" in the game. This given by a fixed
grid of static entries that specify what is to be drawn and give information
On how the user is supposed to interact with it. It also has a list of
objects that are in the room. This includes both the static and moving
entities for the game.


Method Summary
 voidaddEntity(GameEntity ge)
          Add the specified entity to the list for this screen.
 IteratorcreateEntityIterator()
          Returns an Iterator object that can be used to "walk through" the list of
entities on this screen.
 ContainereditPropertiesPanel()
          This method returns a panel that should be set up so that users can
edit the properties of this screen.
 BlockgetBlock(int x, int y)
          Returns the block at location x,y.
 BlockgetBlockOfType(int type)
          Takes a number between 0 and getNumBlockTypes()-1 and returns an
instance of a block corresponding to that number.
 GameEntitygetEntityOfType(int type)
          Takes a number between 0 and getNumEntityTypes()-1 and returns an
instance of an entity corresponding to that number.
 intgetNumBlockTypes()
          Returns the number of different blocks that the screen editor should
set up for adding on this type of screen.
 intgetNumEntityTypes()
          Returns the number of different entities that the screen editor should
set up for adding on this type of screen.
 DimensiongetSize()
          This method returns how many blocks the screen is in width and height.
 voidremoveEntity(GameEntity ge)
          This method searches for the specified entity in this screen and removes
it if found.
 voidsetBlock(int x, int y, Block b)
          Sets the block at location x,y to be b.

Method Detail

addEntity

public void addEntity(GameEntity ge)
Add the specified entity to the list for this screen.
Parameters:
ge This is the entity that is to be added to the screen.

createEntityIterator

public Iterator createEntityIterator()
Returns an Iterator object that can be used to "walk through" the list of
entities on this screen. See java.util.Iterator for the methods of the
Iterator interface. All of the objects returned by the iterator should
be of type GameEntity. If they aren't the display code will throw an
exception when it tries to draw them. Your implementation does not need
to be able to support the remove operation. It is optional, but if you
don't you should write the method to throw an UnsupportedOperationException.
Returns: An Iterator object that will walk the list of entities on this screen.
See Also:
Iterator

editPropertiesPanel

public Container editPropertiesPanel()
This method returns a panel that should be set up so that users can
edit the properties of this screen. Screen properties might include
the size of the screen. The returned value can be any java.awt.Container
though I recommend that you use javax.swing.JPanel.
Returns: A Container with a GUI set up for editing properties. If there are no editable properties it should return null.

getBlock

public Block getBlock(int x, int y)
Returns the block at location x,y.
Parameters:
x The x location of where you are looking.
y The y location of where you are looking.
Returns: The block at that location.

getBlockOfType

public Block getBlockOfType(int type)
Takes a number between 0 and getNumBlockTypes()-1 and returns an
instance of a block corresponding to that number. As mentioned with
getNumBlockTypes() they don't actually have to be different types, they
can be the same type, but with different properties if that helps.
Parameters:
type The integer specifying what type to return.
Returns: A block of the type associated with the input integer.

getEntityOfType

public GameEntity getEntityOfType(int type)
Takes a number between 0 and getNumEntityTypes()-1 and returns an
instance of an entity corresponding to that number. As mentioned with
getNumEntityTypes() they don't actually have to be different types, they
can be the same type, but with different properties if that helps.
Your Player type should NOT be one of the types returned by this.
Parameters:
type The integer specifying what type to return.
Returns: An entity of the type associated with the input integer.

getNumBlockTypes

public int getNumBlockTypes()
Returns the number of different blocks that the screen editor should
set up for adding on this type of screen. Note that this doesn't have to
actually be all your types, or certain blocks could count more than once.
If a block has two or more commonly used different parameter values it
might be easier to treat them as more than one type for use in the
editor.
Returns: Number of block types.

getNumEntityTypes

public int getNumEntityTypes()
Returns the number of different entities that the screen editor should
set up for adding on this type of screen. Note that this doesn't have to
actually be all your types, or certain entities could count more than once.
If an entity has two or more commonly used different parameter values it
might be easier to treat them as more than one type for use in the
editor. This is less significant for entities than blocks because there
are typically few entities on a screen and many blocks.
Returns: Number of entity types.

getSize

public Dimension getSize()
This method returns how many blocks the screen is in width and height.
Returns: Returns an object of type Dimension with the size of the screen in blocks.
See Also:
Dimension

removeEntity

public void removeEntity(GameEntity ge)
throws java.util.NoSuchElementException
This method searches for the specified entity in this screen and removes
it if found. If not found it throws an exception.
Parameters:
ge The GameEntity that you want to remove from this screen.

setBlock

public void setBlock(int x, int y, Block b)
Sets the block at location x,y to be b.
Parameters:
x The x location to be set.
y The y location to be set.
b The block that you want it to be set to.