edu.trinity.cs.gamecore.basic
Class BasicScreen

java.lang.Object
  extended by edu.trinity.cs.gamecore.basic.BasicScreen
All Implemented Interfaces:
Screen<BasicBlock,BasicEntity>, java.io.Serializable

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

This class is a very basic implementation of the Screen interface. You will write your own, but this one is included for the first assignment.

See Also:
Serialized Form

Constructor Summary
BasicScreen()
           
BasicScreen(int sx, int sy)
           
 
Method Summary
 void addEntity(BasicEntity ge)
          Add the specified entity to the list for this screen.
 java.util.Iterator<BasicEntity> 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.
 BasicBlock getBlock(int x, int y)
          Returns the block at location x,y.
 BasicBlock getBlockOfType(int type)
          Takes a number between 0 and getNumBlockTypes()-1 and returns an instance of a block corresponding to that number.
 BasicEntity 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(BasicEntity ge)
          This method searches for the specified entity in this screen and removes it if found.
 void setBlock(int x, int y, BasicBlock b)
          Sets the block at location x,y to be b.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicScreen

public BasicScreen()

BasicScreen

public BasicScreen(int sx,
                   int sy)
Method Detail

getBlock

public BasicBlock getBlock(int x,
                           int y)
Description copied from interface: Screen
Returns the block at location x,y.

Specified by:
getBlock in interface Screen<BasicBlock,BasicEntity>
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

public java.awt.Dimension getSize()
Description copied from interface: Screen
This method returns how many blocks the screen is in width and height.

Specified by:
getSize in interface Screen<BasicBlock,BasicEntity>
Returns:
Returns an object of type Dimension with the size of the screen in blocks.
See Also:
Dimension

getNumBlockTypes

public int getNumBlockTypes()
Description copied from interface: Screen
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.

Specified by:
getNumBlockTypes in interface Screen<BasicBlock,BasicEntity>
Returns:
Number of block types.

getNumEntityTypes

public int getNumEntityTypes()
Description copied from interface: Screen
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.

Specified by:
getNumEntityTypes in interface Screen<BasicBlock,BasicEntity>
Returns:
Number of entity types.

setBlock

public void setBlock(int x,
                     int y,
                     BasicBlock b)
Description copied from interface: Screen
Sets the block at location x,y to be b.

Specified by:
setBlock in interface Screen<BasicBlock,BasicEntity>
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

public BasicBlock getBlockOfType(int type)
Description copied from interface: Screen
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.

Specified by:
getBlockOfType in interface Screen<BasicBlock,BasicEntity>
Parameters:
type - The integer specifying what type to return.
Returns:
A block of the type associated with the input integer.

getEntityOfType

public BasicEntity getEntityOfType(int type)
Description copied from interface: Screen
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.

Specified by:
getEntityOfType in interface Screen<BasicBlock,BasicEntity>
Parameters:
type - The integer specifying what type to return.
Returns:
An entity of the type associated with the input integer.

addEntity

public void addEntity(BasicEntity ge)
Description copied from interface: Screen
Add the specified entity to the list for this screen.

Specified by:
addEntity in interface Screen<BasicBlock,BasicEntity>
Parameters:
ge - This is the entity that is to be added to the screen.

removeEntity

public void removeEntity(BasicEntity ge)
                  throws java.util.NoSuchElementException
Description copied from interface: Screen
This method searches for the specified entity in this screen and removes it if found. If not found it throws an exception.

Specified by:
removeEntity in interface Screen<BasicBlock,BasicEntity>
Parameters:
ge - The GameEntity that you want to remove from this screen.
Throws:
java.util.NoSuchElementException

editPropertiesPanel

public java.awt.Container editPropertiesPanel()
Description copied from interface: Screen
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.

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

createEntityIterator

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

Specified by:
createEntityIterator in interface Screen<BasicBlock,BasicEntity>
Returns:
An Iterator object that will walk the list of entities on this screen.
See Also:
<{Iterator}>