public abstract class VGDLSprite
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
int |
bucket
Bucket
|
boolean |
bucketSharp
Bucket remainder.
|
java.awt.Color |
color
Color of this sprite.
|
int |
cooldown
States the pause ticks in-between two moves
|
boolean |
draw_arrow
Tells if an arrow must be drawn to indicate the orientation of the sprite.
|
java.awt.Image |
image
Image of this sprite.
|
java.lang.String |
img
String that represents the image in VGDL.
|
boolean |
invisible
Indicates if the sprite is invisible.
|
boolean |
is_avatar
Indicates if this sprite is the avatar (player) of the game.
|
boolean |
is_from_avatar
Indicates if this sprite was created by the avatar.
|
boolean |
is_npc
Indicates if this sprite is an NPC.
|
boolean |
is_oriented
Indicates if this sprite has an oriented behaviour.
|
boolean |
is_resource
Indicates if this sprite is a resource.
|
boolean |
is_static
Indicates if this sprite is static or not.
|
boolean |
is_stochastic
Indicates if the sprite has a stochastic behaviour.
|
java.util.ArrayList<java.lang.Integer> |
itypes
List of types this sprite belongs to.
|
int |
lastmove
Tells how many timesteps ago was the last move
|
java.awt.Rectangle |
lastrect
Rectangle occupied for this sprite in the previous game step.
|
double |
mass
Mass of this sprite (for Continuous physics).
|
java.lang.String |
name
Name of this sprite.
|
boolean |
only_active
Indicates if passive movement is denied for this sprite.
|
Vector2d |
orientation
Orientation of the sprite.
|
Physics |
physics
Reference to the physics object this sprite belongs to.
|
java.lang.String |
physicstype
String that represents the physics type of this sprite.
|
int |
physicstype_id
Id of the type if physics this sprite responds to.
|
boolean |
portal
Indicates if this sprite is a portal.
|
java.awt.Rectangle |
rect
Rectangle that this sprite occupies on the screen.
|
java.util.TreeMap<java.lang.Integer,java.lang.Integer> |
resources
Indicates the amount of resources this sprite has, for each type defined as its int identifier.
|
double |
shrinkfactor
Scale factor to draw this sprite.
|
boolean |
singleton
Indicates if this sprite is a singleton.
|
double |
speed
Scalar speed of this sprite.
|
int |
spriteID
ID of this sprite.
|
double |
strength
Strength measure of this sprite.
|
Constructor and Description |
---|
VGDLSprite() |
Modifier and Type | Method and Description |
---|---|
void |
_draw(java.awt.Graphics2D gphx,
Game game)
Draws the not-oriented part of the sprite
|
void |
_drawImage(java.awt.Graphics2D gphx,
Game game)
Draws the not-oriented part of the sprite, as an image.
|
void |
_drawOriented(java.awt.Graphics2D g)
In case this sprite is oriented and has an arrow to draw, it draws it.
|
protected void |
_drawResources(java.awt.Graphics2D gphx,
Game game)
Draws the resources hold by this sprite, as an horizontal bar on top of the sprite.
|
void |
_updatePos(Vector2d orientation,
int speed)
Updates the position of the sprite, giving its orientation and speed.
|
Vector2d |
_velocity()
Returns the velocity of the sprite, in a Vector2d object.
|
void |
applyMovement(boolean[] actionMask)
Applies both the passive and active movement for the avatar in the forward model.
|
abstract VGDLSprite |
copy()
Creates a copy of this sprite.
|
void |
copyTo(VGDLSprite toSprite)
Copies the attributes of this object to the one passed as parameter.
|
void |
draw(java.awt.Graphics2D gphx,
Game game)
Draws this sprite (both the not oriented and, if appropriate, the oriented part)
|
int |
getAmountResource(int resourceId)
Returns the amount of resource of a given type this sprite has.
|
Vector2d |
getPosition()
Gets the position of this sprite.
|
int |
getType()
Gets the unique and precise type of this sprite
|
protected void |
init(Vector2d position,
java.awt.Dimension size)
Initializes the sprite, giving its position and dimensions.
|
Vector2d |
lastDirection()
Returns the last direction this sprite is following.
|
protected void |
loadDefaults()
Loads the default values for this sprite.
|
void |
loadImage(java.lang.String str)
Loads the image that represents this sprite, using its string name as reference.
|
void |
modifyResource(int resourceId,
int amount_delta)
Modifies the amount of resource by a given quantity.
|
void |
parseParameters(SpriteContent content)
Parses parameters for the sprite, received as a SpriteContent object.
|
void |
postProcess()
Method to perform post processing when the sprite has received its parameters.
|
void |
setFromAvatar(boolean fromAvatar)
Used to indicate if this sprite was created by the avatar.
|
void |
setRect(java.awt.Rectangle rectangle) |
void |
setRect(Vector2d position,
java.awt.Dimension size) |
java.lang.String |
toString()
Returns a string representation of this string, including its name and position.
|
void |
update(Game game)
Updates this sprite, performing the movements and actions for the next step.
|
void |
updatePassive()
Updates this sprite applying the passive movement.
|
public java.lang.String name
public boolean is_static
public boolean only_active
public boolean is_avatar
public boolean is_stochastic
public java.awt.Color color
public int cooldown
public double speed
public double mass
public int physicstype_id
public java.lang.String physicstype
public Physics physics
public double shrinkfactor
public boolean is_oriented
public boolean draw_arrow
public Vector2d orientation
public java.awt.Rectangle rect
public java.awt.Rectangle lastrect
public int lastmove
public double strength
public boolean singleton
public boolean is_resource
public boolean portal
public boolean invisible
public java.util.ArrayList<java.lang.Integer> itypes
public java.util.TreeMap<java.lang.Integer,java.lang.Integer> resources
public java.awt.Image image
public java.lang.String img
public boolean is_npc
public int spriteID
public boolean is_from_avatar
public int bucket
public boolean bucketSharp
protected void init(Vector2d position, java.awt.Dimension size)
position
- position of the spritesize
- dimensions of the sprite on the screen.public void setRect(Vector2d position, java.awt.Dimension size)
public void setRect(java.awt.Rectangle rectangle)
protected void loadDefaults()
public void parseParameters(SpriteContent content)
content
- public void update(Game game)
game
- the current game that is being played.public void applyMovement(boolean[] actionMask)
public void updatePassive()
public void _updatePos(Vector2d orientation, int speed)
orientation
- the orientation of the sprite.speed
- the speed of the sprite.public Vector2d _velocity()
public Vector2d lastDirection()
public Vector2d getPosition()
public void modifyResource(int resourceId, int amount_delta)
resourceId
- id of the resource whose quantity must be changed.amount_delta
- amount of units the resource has to be modified by.public int getAmountResource(int resourceId)
resourceId
- id of the resource to check.public void draw(java.awt.Graphics2D gphx, Game game)
gphx
- graphics object to draw in.game
- reference to the game that is being played now.public void _drawOriented(java.awt.Graphics2D g)
g
- graphics device to draw in.public void _draw(java.awt.Graphics2D gphx, Game game)
gphx
- graphics object to draw in.game
- reference to the game that is being played now.public void _drawImage(java.awt.Graphics2D gphx, Game game)
gphx
- graphics object to draw in.game
- reference to the game that is being played now.protected void _drawResources(java.awt.Graphics2D gphx, Game game)
gphx
- graphics to draw in.game
- game being played at the moment.public int getType()
public void postProcess()
public void loadImage(java.lang.String str)
str
- name of the image to load.public void setFromAvatar(boolean fromAvatar)
fromAvatar
- true if the avatar created this sprite.public java.lang.String toString()
toString
in class java.lang.Object
public abstract VGDLSprite copy()
public void copyTo(VGDLSprite toSprite)
toSprite
- the sprite to copy to.