edu.trinity.cs.gamecore
Class StickPlayer<B extends Block<B,E>,E extends GameEntity<B,E>>

java.lang.Object
  extended by edu.trinity.cs.gamecore.StickPlayer<B,E>
All Implemented Interfaces:
GameEntity<B,E>, Player<B,E>, java.awt.event.KeyListener, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
BasicPlayer

public class StickPlayer<B extends Block<B,E>,E extends GameEntity<B,E>>
extends java.lang.Object
implements Player<B,E>, java.awt.event.KeyListener

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface edu.trinity.cs.gamecore.Player
Player.GameStatus, Player.PanelLoc
 
Constructor Summary
StickPlayer(Location<B,E> loc)
           
 
Method Summary
 boolean followLinks()
          Tells if this entity should follow links from one screen to another.
 Player.GameStatus gameStatus()
          Returns one of the three constants above telling what the status of the game is.
 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.Container getGameStatusPanel(Player.PanelLoc loc)
          This method returns a GUI container that shows extra information in your game.
 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.
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
          I'm not using this because it is linked to the key repeat rate.
 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)
          This is the method that should be called to update the player.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StickPlayer

public StickPlayer(Location<B,E> loc)
Method Detail

gameStatus

public Player.GameStatus gameStatus()
Description copied from interface: Player
Returns one of the three constants above telling what the status of the game is.

Specified by:
gameStatus in interface Player<B extends Block<B,E>,E extends GameEntity<B,E>>

getGameStatusPanel

public java.awt.Container getGameStatusPanel(Player.PanelLoc loc)
Description copied from interface: Player
This method returns a GUI container that shows extra information in your game. For example, this might be where you display the score to the user. I recommend that you use a JPanel here, but it should work with any form of java.awt.Container. This region can be interactive as well if it has elements in it that handle events. In some games this might be where you can select options of things like that. It should return null if nothing is to be displayed. The argument says which area this panel is for. It should be one of the PanelLoc constants such as NORTH;

Specified by:
getGameStatusPanel in interface Player<B extends Block<B,E>,E extends GameEntity<B,E>>
Parameters:
loc - This integer specifies which side of the display the panel is being requested for.
Returns:
The panel that should go at that location or null if none.

update

public void update(int time)
This is the method that should be called to update the player. I did some extra work to make this smarter on 1-50-78.

Specified by:
update in interface GameEntity<B extends Block<B,E>,E extends GameEntity<B,E>>
Parameters:
time - This is the time for the tick when this ic called.

getUpdateTime

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

Specified by:
getUpdateTime in interface GameEntity<B extends Block<B,E>,E extends GameEntity<B,E>>
Returns:
The next time that this entity should be updated or -1 if it shouldn't be.

getLocation

public Location<B,E> getLocation()
Description copied from interface: GameEntity
This returns the location of this entity.

Specified by:
getLocation in interface GameEntity<B extends Block<B,E>,E extends GameEntity<B,E>>
Returns:
The current location of this entity.

setLocation

public void setLocation(Location<B,E> loc)
Description copied from interface: GameEntity
This sets the location of this entity.

Specified by:
setLocation in interface GameEntity<B extends Block<B,E>,E extends GameEntity<B,E>>

getImage

public java.awt.Image getImage()
Description copied from interface: GameEntity
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.

Specified by:
getImage in interface GameEntity<B extends Block<B,E>,E extends GameEntity<B,E>>
Returns:
The image that is to be drawn for this entity.

partialSizeX

public int partialSizeX()
Description copied from interface: GameEntity
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();

Specified by:
partialSizeX in interface GameEntity<B extends Block<B,E>,E extends GameEntity<B,E>>
Returns:
How many partials across the entity should take up when drawn.

partialSizeY

public int partialSizeY()
Description copied from interface: GameEntity
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();

Specified by:
partialSizeY in interface GameEntity<B extends Block<B,E>,E extends GameEntity<B,E>>
Returns:
How many partials vertically the entity should take up when drawn.

getEditPropertiesPanel

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

Specified by:
getEditPropertiesPanel in interface GameEntity<B extends Block<B,E>,E extends GameEntity<B,E>>
Returns:
A GUI entity used in the editor to change entity properties.

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
I'm not using this because it is linked to the key repeat rate. I'm also not certain that is works with up, down, left, and right.

Specified by:
keyTyped in interface java.awt.event.KeyListener

followLinks

public boolean followLinks()
Description copied from interface: GameEntity
Tells if this entity should follow links from one screen to another.

Specified by:
followLinks in interface GameEntity<B extends Block<B,E>,E extends GameEntity<B,E>>
Returns:
A boolean value telling if it follows links or not.