public abstract class VGDLSprite
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
boolean |
autotiling
Indicates if the tile support autotiling
|
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
|
int |
currentFrame
the current frame to be drawn
|
boolean |
draw_arrow
Tells if an arrow must be drawn to indicate the orientation of the sprite.
|
double |
frameRate
max frameRate for animating sprites
|
double |
frameRemaining
remaining frame speed
|
double |
friction
The amount of friction this sprite has when moving.
|
double |
gravity
The amount of gravity force that pushes down on the sprite
|
int |
healthPoints
Health points of this sprite.
|
java.lang.String |
hidden
If true, this sprite is never present in the observations passed to the controller.
|
double |
hMult |
java.awt.Image |
image
Unique and current image of this sprite.
|
java.util.HashMap<java.lang.String,java.util.ArrayList<java.awt.Image>> |
images
All images in case there's orientation changes and/or animations.
|
java.lang.String |
img
String that represents the image in VGDL.
|
java.lang.String |
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.
|
boolean |
isFirstTick
Indicates if the sprite is in its first cycle of existence.
|
java.util.ArrayList<java.lang.Integer> |
itypes
List of types this sprite belongs to.
|
double |
jump_strength
Strength measure of this sprite.
|
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.
|
int |
limitHealthPoints
Limit of health points of this can have.
|
double |
mass
Mass of this sprite (for Continuous physics).
|
double |
max_speed
Maximum speed of the sprites
|
int |
maxHealthPoints
Maximum health points of this sprite.
|
java.lang.String |
name
Name of this sprite.
|
boolean |
on_ground
Is the sprite on ground?
|
boolean |
only_active
Indicates if passive movement is denied for this sprite.
|
Direction |
orientation
Orientation of the sprite.
|
java.lang.String |
orientedImg
String that represents the image in VGDL.
|
Physics |
physics
Reference to the physics object this sprite belongs to.
|
int |
physicstype
Id of the type if physics this sprite responds to.
|
boolean |
portal
Indicates if this sprite is a portal.
|
double |
randomtiling
Indicates if the tile picking is random
|
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.
|
boolean |
rotateInPlace
Indicates if the sprite is able to rotate in place.
|
double |
rotation
The sprites rotation
|
double |
shrinkfactor
Scale factor to draw this sprite.
|
boolean |
singleton
Indicates if this sprite is a singleton.
|
java.awt.Dimension |
size
The sprites size
|
boolean |
solid
Is this a SOLID sprite?
|
double |
speed
Scalar speed of this sprite.
|
int |
spriteID
ID of this sprite.
|
boolean |
stationary
identifies whether this sprite should move (if an Avatar)
|
int |
timeToLive
Time to live for this sprite.
|
double |
wMult
Multipliers for sprite's rectangle size
|
Constructor and Description |
---|
VGDLSprite() |
Modifier and Type | Method and Description |
---|---|
void |
_draw(java.awt.Graphics2D gphx,
Game game,
java.awt.Rectangle r)
Draws the not-oriented part of the sprite
|
protected void |
_drawHealthBar(java.awt.Graphics2D gphx,
Game game,
java.awt.Rectangle r)
Draws the health bar, as a vertical bar on top (and left) of the sprite.
|
void |
_drawImage(java.awt.Graphics2D gphx,
Game game,
java.awt.Rectangle r)
Draws the not-oriented part of the sprite, as an image. this.image must be not null.
|
void |
_drawOriented(java.awt.Graphics2D g,
java.awt.Rectangle r)
In case this sprite is oriented and has an arrow to draw, it draws it.
|
protected void |
_drawResources(java.awt.Graphics2D gphx,
Game game,
java.awt.Rectangle r)
Draws the resources hold by this sprite, as an horizontal bar on top of the sprite.
|
boolean |
_updateOrientation(Direction orientation)
Updates the orientation of the avatar to match the orientation parameter.
|
boolean |
_updatePos(Direction orientation,
int speed)
Updates the position of the sprite, giving its orientation and speed.
|
boolean |
_updateRotation(double rot) |
Vector2d |
_velocity()
Returns the velocity of the sprite, in a Vector2d object.
|
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)
|
boolean |
equiv(java.lang.Object o)
Determines if two the object passed is equal to this.
|
int |
getAmountResource(int resourceId)
Returns the amount of resource of a given type this sprite has.
|
java.util.ArrayList<java.lang.String> |
getDependentSprites()
Get all sprites that affect or being affected by the current sprite
|
Vector2d |
getLastPosition()
Gets the last position of this sprite.
|
Vector2d |
getPosition()
Gets the position of this sprite.
|
int |
getType()
Gets the unique and precise type of this sprite
|
boolean |
groundIntersects(VGDLSprite sp)
Overwritting intersects to check if we are on ground.
|
protected void |
init(Vector2d position,
java.awt.Dimension size)
Initializes the sprite, giving its position and dimensions.
|
boolean |
intersects(VGDLSprite sp)
Checks if this sprites intersects with the one received as parameter.
|
boolean |
is_disabled()
Check if this sprite is disabled.
|
Vector2d |
lastDirection()
Returns the last direction this sprite is following.
|
protected void |
loadDefaults()
Loads the default values for this sprite.
|
void |
loadImage()
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 |
preMovement()
Prepares the sprite for movement.
|
void |
removeResource(int resourceId)
Removes all resources collected of the specified type.
|
void |
setDisabled(boolean is_disabled)
Set the disabled flag of this sprite.
|
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) |
void |
subtractResource(int resourceId,
int amount_delta) |
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 |
updateAvatar(Game game,
boolean request,
boolean[] actionMask) |
void |
updateBucket() |
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 boolean stationary
public double mass
public int physicstype
public Physics physics
public double gravity
public double friction
public double shrinkfactor
public boolean is_oriented
public boolean draw_arrow
public Direction orientation
public java.awt.Rectangle rect
public java.awt.Rectangle lastrect
public int lastmove
public double jump_strength
public boolean singleton
public boolean is_resource
public boolean portal
public java.lang.String invisible
public java.lang.String hidden
public boolean autotiling
public double randomtiling
public double frameRate
public double frameRemaining
public int currentFrame
public java.util.ArrayList<java.lang.Integer> itypes
public java.util.TreeMap<java.lang.Integer,java.lang.Integer> resources
public java.util.HashMap<java.lang.String,java.util.ArrayList<java.awt.Image>> images
public java.awt.Image image
public java.lang.String img
public java.lang.String orientedImg
public boolean is_npc
public int spriteID
public boolean is_from_avatar
public int bucket
public boolean bucketSharp
public boolean rotateInPlace
public boolean isFirstTick
public int healthPoints
public int maxHealthPoints
public int limitHealthPoints
public int timeToLive
public double rotation
public double wMult
public double hMult
public java.awt.Dimension size
public boolean on_ground
public boolean solid
public double max_speed
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 updateAvatar(Game game, boolean request, boolean[] actionMask)
public void setDisabled(boolean is_disabled)
is_disabled
- - disabled statepublic boolean is_disabled()
public void preMovement()
public void updatePassive()
public boolean _updateOrientation(Direction orientation)
orientation
- final orientation the avatar must have.public boolean _updatePos(Direction orientation, int speed)
orientation
- the orientation of the sprite.speed
- the speed of the sprite.public boolean _updateRotation(double rot)
rot
- the rotation of the spritepublic void updateBucket()
public Vector2d _velocity()
public boolean intersects(VGDLSprite sp)
sp
- the other sprite to check collisions withpublic Vector2d lastDirection()
public Vector2d getPosition()
public Vector2d getLastPosition()
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 void subtractResource(int resourceId, int amount_delta)
public void removeResource(int resourceId)
resourceId
- - id of the resource whose quantity must be changed.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 boolean groundIntersects(VGDLSprite sp)
public void _drawOriented(java.awt.Graphics2D g, java.awt.Rectangle r)
g
- graphics device to draw in.public void _draw(java.awt.Graphics2D gphx, Game game, java.awt.Rectangle r)
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, java.awt.Rectangle r)
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, java.awt.Rectangle r)
gphx
- graphics to draw in.game
- game being played at the moment.protected void _drawHealthBar(java.awt.Graphics2D gphx, Game game, java.awt.Rectangle r)
gphx
- graphics to draw in.game
- game being played at the moment.r
- rectangle of this sprite.public int getType()
public void postProcess()
public void loadImage()
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.public boolean equiv(java.lang.Object o)
public java.util.ArrayList<java.lang.String> getDependentSprites()