|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.golden.gamedev.object.Sprite
com.golden.gamedev.object.AnimatedSprite
gameobjects.AbstractGameObject
gameobjects.characters.AbstractCharacterSprite
gameobjects.characters.Player
public class Player
This class represents the main character sprite of the game. This character is controlled by the player.
Field Summary | |
---|---|
static java.lang.String |
DIGGING
|
static java.lang.String |
STANDARD
Constant that refers to the standard animation of a game object |
static java.lang.String |
TALK
constant refering to the talking animation |
static java.lang.String |
WAIT
constant refering to the waiting animation |
static java.lang.String |
WALK_LEFT
constant refering to the walking left animation |
static java.lang.String |
WALK_RIGHT
constant refering to the walking right animation |
Fields inherited from class gameobjects.characters.AbstractCharacterSprite |
---|
DIR_LEFT, DIR_NO_DIR, DIR_RIGHT |
Constructor Summary | |
---|---|
Player(java.lang.String name,
java.lang.String bshName,
double x,
double y,
java.awt.Color speachColor,
com.golden.gamedev.engine.BaseLoader bsLoader,
com.golden.gamedev.engine.BaseInput bsInput,
com.golden.gamedev.engine.BaseAudio bsSound)
Creates a new player sprite. |
Method Summary | |
---|---|
void |
addDialog(Dialog dialog)
Adds a dialog to the set of player dialogs |
Dialog |
getDialog(java.lang.String name)
|
Item |
getInventItem()
Convenience method for simpler use in beanshell scripts to get the player's currently selected inventory item. |
Inventory |
getInventory()
Returns the player's inventory containing the collected items |
boolean |
hasArrivedAtTarget()
Returns whether the player has arrived at his designated target location. |
boolean |
hasItem(Item item)
Convenience method to check if the specified item is contained in the player's inventory |
boolean |
isInDialog()
Determines whether the player is currently making conversation |
boolean |
isLookingAtInventory()
Convenience method to determine whether the player is currently looking at the inventory |
void |
loseItem(Item item)
Convenience method to remove an item from the player's inventory |
void |
pickItem(Item item)
Takes an item and adds it to the player's inventory while removing it from the game location it was taken from |
void |
render(java.awt.Graphics2D g)
|
void |
runDialog(java.lang.String dialogName)
Convenience method to run the dialog for the player |
void |
setHasArrivedAtTarget(boolean arrived)
Sets whether the player has arrived at target |
void |
setIsInDialog(boolean isInDialog)
Sets the dialog current status of the player |
void |
update(long elapsedTime)
|
boolean |
uses(Item item)
This method checks, if the currently selected inventory item is equal to the specified item. |
Methods inherited from class gameobjects.characters.AbstractCharacterSprite |
---|
addAction, addActions, getDirection, getGameActionScheduler, getPreviousDirection, getSpeechColor, getTargetX, getTargetY, hasJustUsedExit, pause, resume, setDirection, setJustUsedExit, setTargetPosition, setTargetX, setTargetY |
Methods inherited from class gameobjects.AbstractGameObject |
---|
compareTo, getAnimPool, getAnimScheduler, getBshName, getBsLoader, getDescription, getGameLocation, getHotspot, getMidX, getMidY, getName, isPicked, setDescription, setGameLocation, setName, setToPicked |
Methods inherited from class com.golden.gamedev.object.AnimatedSprite |
---|
getAnimationTimer, getFinishAnimationFrame, getFrame, getImage, getImage, getImages, getStartAnimationFrame, isAnimate, isLoopAnim, render, setAnimate, setAnimationFrame, setAnimationTimer, setFrame, setImage, setImages, setLoopAnim |
Methods inherited from class com.golden.gamedev.object.Sprite |
---|
addHorizontalSpeed, addVerticalSpeed, forceX, forceY, getBackground, getDataID, getDistance, getHeight, getHorizontalSpeed, getID, getLayer, getOldX, getOldY, getScreenX, getScreenY, getVerticalSpeed, getWidth, getX, getY, isActive, isImmutable, isOnScreen, isOnScreen, move, moveTo, moveX, moveY, setActive, setBackground, setDataID, setHorizontalSpeed, setID, setImmutable, setLayer, setLocation, setMovement, setSpeed, setVerticalSpeed, setX, setY |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String STANDARD
public static final java.lang.String WAIT
public static final java.lang.String WALK_RIGHT
public static final java.lang.String WALK_LEFT
public static final java.lang.String TALK
public static final java.lang.String DIGGING
Constructor Detail |
---|
public Player(java.lang.String name, java.lang.String bshName, double x, double y, java.awt.Color speachColor, com.golden.gamedev.engine.BaseLoader bsLoader, com.golden.gamedev.engine.BaseInput bsInput, com.golden.gamedev.engine.BaseAudio bsSound)
name
- Name of the player characterbshName
- name that will be used for the player in
beanshell scripts. I recommend to simply use "player" as the
beanshell namex
- x-coordinate, where the sprite should initially appeary
- y-coordinate, where the sprite should initially appearspeachColor
- color for the spoken dialog lines on screenbsLoader
- the BaseLoader object from the Main classbsSound
- the BaseAudio object from the Main classbsInput
- the BaseInput object from the Main classMethod Detail |
---|
public boolean hasArrivedAtTarget()
public void setHasArrivedAtTarget(boolean arrived)
arrived
- has arrived? --> true=yes, false=nopublic Inventory getInventory()
public boolean isLookingAtInventory()
public boolean isInDialog()
public void setIsInDialog(boolean isInDialog)
isInDialog
- is making conversation? --> true=yes, false=nopublic void runDialog(java.lang.String dialogName)
dialogName
- indentifying name of the dialog to
apply with the playerpublic void addDialog(Dialog dialog)
dialog
- the dialog to addpublic Dialog getDialog(java.lang.String name)
public Item getInventItem()
public boolean uses(Item item)
item
- item to check for use
public boolean hasItem(Item item)
item
- item to check for existence in the player's inventory
public void pickItem(Item item)
item
- item to pick and add to the player's inventorypublic void loseItem(Item item)
item
- item to remove from inventorypublic void update(long elapsedTime)
update
in class AbstractCharacterSprite
public void render(java.awt.Graphics2D g)
render
in class AbstractCharacterSprite
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |