edu.trinity.cs.gamecore
Interface GameEntity<B extends Block<B,E>,E extends GameEntity<B,E>>
- All Superinterfaces:
- java.io.Serializable
- All Known Subinterfaces:
- BasicEntity, Player<B,E>
- All Known Implementing Classes:
- BasicEntityImpl, BasicPlayer, EditorPlayer, StickPlayer
public interface GameEntity<B extends Block<B,E>,E extends GameEntity<B,E>>
- extends java.io.Serializable
This interface will be implemented for any class that should represent an
entity in the game. Player is a subclass of this. The entities are all objects
that move or have animations in the game.
This class is a generic that takes the general block type and the general
entity type for each game.
Method Summary |
boolean |
followLinks()
Tells if this entity should follow links from one screen to another. |
java.awt.Container |
getEditPropertiesPanel()
This method should return a java.awt.Container with GUI components set
up in it to edit the properties of this entity. |
java.awt.Image |
getImage()
This returns the image that should be drawn for this entity. |
Location<B,E> |
getLocation()
This returns the location of this entity. |
int |
getUpdateTime()
This method returns the next time at which the entity should have its
update method called. |
int |
partialSizeX()
This method returns how many partials across the entity should be. |
int |
partialSizeY()
This method returns how many partials up and down the entity should be. |
void |
setLocation(Location<B,E> loc)
This sets the location of this entity. |
void |
update(int time)
The update method is where any changes to the entity are made. |
getUpdateTime
int getUpdateTime()
- This method returns the next time at which the entity should have its
update method called. A negative value prevents it from being put on
the event queue.
- Returns:
- The next time that this entity should be updated or -1 if it shouldn't be.
update
void update(int time)
- The update method is where any changes to the entity are made. This
will mainly be moving the object, but can also include collision
detection and handling with other things in the game and updating
animations.
- Parameters:
time
- This is the current time in the game.
getLocation
Location<B,E> getLocation()
- This returns the location of this entity.
- Returns:
- The current location of this entity.
setLocation
void setLocation(Location<B,E> loc)
- This sets the location of this entity.
getImage
java.awt.Image getImage()
- This returns the image that should be drawn for this entity. What is
returned will be scaled to the size of one block for drawing.
- Returns:
- The image that is to be drawn for this entity.
partialSizeX
int partialSizeX()
- This method returns how many partials across the entity should be. For a "standard"
entity that take up a whole block, this should return Location.getPartialsInWhole();
- Returns:
- How many partials across the entity should take up when drawn.
partialSizeY
int partialSizeY()
- This method returns how many partials up and down the entity should be. For a "standard"
entity that take up a whole block, this should return Location.getPartialsInWhole();
- Returns:
- How many partials vertically the entity should take up when drawn.
getEditPropertiesPanel
java.awt.Container getEditPropertiesPanel()
- This method should return a java.awt.Container with GUI components set
up in it to edit the properties of this entity. The entity should not
have a reference to the Container because that could interfer with
saving to disk. I recommend using a javax.swing.JPanel as your Container,
but any Container should work. This method is only called in the
screen editor, not during the game. If your entity doesn't have any
properties that should be changable in the editor this should return null.
- Returns:
- A GUI entity used in the editor to change entity properties.
followLinks
boolean followLinks()
- Tells if this entity should follow links from one screen to another.
- Returns:
- A boolean value telling if it follows links or not.