gameobjects.item
Class Item

java.lang.Object
  extended by com.golden.gamedev.object.Sprite
      extended by com.golden.gamedev.object.AnimatedSprite
          extended by gameobjects.AbstractGameObject
              extended by gameobjects.item.Item
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<AbstractGameObject>

public class Item
extends AbstractGameObject

This class represents an item in the game. Items are objects with which the player can interact in some way.

Author:
Frank Bruns
See Also:
Serialized Form

Constructor Summary
Item(java.lang.String name, java.lang.String bshName, double x, double y, boolean pickable, java.awt.image.BufferedImage inventImage, com.golden.gamedev.engine.BaseLoader bsLoader, com.golden.gamedev.engine.BaseInput bsInput, com.golden.gamedev.engine.BaseAudio bsSound)
          Creates a new item
 
Method Summary
 Hotspot getInventHotspot()
          Returns the hotspot of the item in the inventory
 java.awt.image.BufferedImage getInventoryImage()
          Returns the image that represents the item in the inventory
 java.awt.Point getInventPosition()
          Returns the current position of the item in the inventory.
 java.lang.String getItemName()
          Returns the name of an item
 boolean isInPickingRange(Player player)
          Determines whether the item is within picking range of the player character
 boolean isNotedForPicking()
          Determines whether the item is noted for later picking, so that the item can be picked as soon as the player gets near to it
 boolean isPickable()
          Determines whether the item be picked by the player
 void setInventPosition(java.awt.Point point)
          Sets the inventory position of the item to the specified point
 void setNotedForPicking(boolean noted)
          Sets if the item is noted for picking as soon as the player gets near the item
 void showNameinInventory(java.awt.Graphics2D g)
          Shows the name of the inventory item right below it.
 void update(long elapsedTime)
           
 
Methods inherited from class gameobjects.AbstractGameObject
compareTo, getAnimPool, getAnimScheduler, getBshName, getBsLoader, getDescription, getGameLocation, getHotspot, getMidX, getMidY, getName, isPicked, render, 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
 

Constructor Detail

Item

public Item(java.lang.String name,
            java.lang.String bshName,
            double x,
            double y,
            boolean pickable,
            java.awt.image.BufferedImage inventImage,
            com.golden.gamedev.engine.BaseLoader bsLoader,
            com.golden.gamedev.engine.BaseInput bsInput,
            com.golden.gamedev.engine.BaseAudio bsSound)
Creates a new item

Parameters:
name - name of the item
bshName - name that will be used for this item in beanshell scripts
x - x-coordinate
y - y-coordinate
pickable - is the item pickable by the player?
inventImage - image for the inventory
bsLoader -
bsInput -
bsSound -
Method Detail

getItemName

public java.lang.String getItemName()
Returns the name of an item

Returns:
Item name

getInventPosition

public java.awt.Point getInventPosition()
Returns the current position of the item in the inventory. This method returns null if the item is not pickable and hence could not have become a member of the inventory.

Returns:
position in the inventory area (x,y)-coordinates

setInventPosition

public void setInventPosition(java.awt.Point point)
Sets the inventory position of the item to the specified point

Parameters:
point - new position in the inventory

getInventoryImage

public java.awt.image.BufferedImage getInventoryImage()
Returns the image that represents the item in the inventory

Returns:
The item's inventory image

getInventHotspot

public Hotspot getInventHotspot()
Returns the hotspot of the item in the inventory

Returns:
hotspot of the item in the inventory

isPickable

public boolean isPickable()
Determines whether the item be picked by the player

Returns:
can the player pick the item? --> true=yes, false=no

setNotedForPicking

public void setNotedForPicking(boolean noted)
Sets if the item is noted for picking as soon as the player gets near the item

Parameters:
noted - note the item for later picking --> true=yes, false=no

isNotedForPicking

public boolean isNotedForPicking()
Determines whether the item is noted for later picking, so that the item can be picked as soon as the player gets near to it

Returns:
is item noted for later picking? --> true=yes, false=no

isInPickingRange

public boolean isInPickingRange(Player player)
Determines whether the item is within picking range of the player character

Parameters:
player - player object
Returns:
is item in picking range of the player? true=yes, false=no

showNameinInventory

public void showNameinInventory(java.awt.Graphics2D g)
Shows the name of the inventory item right below it.

Parameters:
g -

update

public void update(long elapsedTime)
Overrides:
update in class AbstractGameObject