edu.trinity.cs.gamecore
Interface Screen<B extends Block<B,E>,E extends GameEntity<B,E>>

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
BasicScreen

public interface Screen<B extends Block<B,E>,E extends GameEntity<B,E>>
extends java.io.Serializable

This class represents a single "screen" in the game. This given by a fixed grid of unchanging 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 moving and non-moving entities for the game.

This class is a generic that takes the general block type and the general entity type for each game.


Method Summary
 void addEntity(E ge)
          Add the specified entity to the list for this screen.
 java.util.Iterator<E> createEntityIterator()
          Returns an Iterator object that can be used to "walk through" the list of entities on this screen.
 java.awt.Container editPropertiesPanel()
          This method returns a panel that should be set up so that users can edit the properties of this screen.
 B getBlock(int x, int y)
          Returns the block at location x,y.
 B getBlockOfType(int type)
          Takes a number between 0 and getNumBlockTypes()-1 and returns an instance of a block corresponding to that number.
 E getEntityOfType(int type)
          Takes a number between 0 and getNumEntityTypes()-1 and returns an instance of an entity corresponding to that number.
 int getNumBlockTypes()
          Returns the number of different blocks that the screen editor should set up for adding on this type of screen.
 int getNumEntityTypes()
          Returns the number of different entities that the screen editor should set up for adding on this type of screen.
 java.awt.Dimension getSize()
          This method returns how many blocks the screen is in width and height.
 void removeEntity(E ge)
          This method searches for the specified entity in this screen and removes it if found.
 void setBlock(int x, int y, B b)
          Sets the block at location x,y to be b.
 

Method Detail

getBlock

B 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.

getSize

java.awt.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

createEntityIterator

java.util.Iterator<E> 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

addEntity

void addEntity(E 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.

removeEntity

void removeEntity(E 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.
Throws:
java.util.NoSuchElementException

getNumBlockTypes

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.

setBlock

void setBlock(int x,
              int y,
              B 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.

getBlockOfType

B 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.

getNumEntityTypes

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.

getEntityOfType

E 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.

editPropertiesPanel

java.awt.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.