Class Actor
java.lang.Object
ActiverseEngine.Actor
The base class for all actors in the world.
- Version:
- 1.4.0
- Author:
- Knivier
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidact()Performs the actor's action.booleanAdds an item to the actor's inventory.voiddelayNext(int ms) Delays the execution of the next action by the specified milliseconds.voidDisables the actor's inventory.voidEnables inventory for the actor.intGets the height of the actor.getImage()Gets the image of the actor.Gets the inventory of the actor.intGets the maximum size of the actor's inventory.Finds the intesrsectiuon of the actor with another actor then returns itdoubleGets the horizontal velocity of the actor.doubleGets the vertical velocity of the actor.intgetWidth()Returns the width of the ActorgetWorld()Gets the world that the actor belongs to.intgetX()Gets the x-coordinate of the actor's location.intgetY()Gets the y-coordinate of the actor's location.booleanChecks if the actor has an inventory.booleanintersects(Actor other) Checks if this actor intersects with another actor.booleanisStatic()Returns the state of the actor on whether it is static or not.booleankeyIsDown(char key) Checks if a specific key is currently pressed.voidmove(int distance) Moves the actor in its current direction by the specified distance.voidDraws the actor on the given graphics context.voidremoveItem(Item item) Removes an item from the actor's inventory.voidsetHeight(int height) Sets the height of the actor.voidsetImage(ActiverseImage image) Sets the image of the actor.voidsetInventorySize(int size) Sets the inventory sizevoidsetLocation(int x, int y) Sets the location of the actor.booleansetStatic(boolean isStatic) Sets the state of the actor to static or not.voidsetVelocityX(double velocityX) Sets the horizontal velocity of the actor.voidsetVelocityY(double velocityY) Sets the vertical velocity of the actor.voidsetWidth(int width) Sets the width of the actor.voidSets the world that the actor belongs to.voidsetX(int x) Sets the x-coordinate of the actor's location.voidsetY(int y) Sets the y-coordinate of the actor's location.voidturn(double angle) Turns the actor by the specified angle.voidGets the direction of the actor.
-
Constructor Details
-
Actor
public Actor()
-
-
Method Details
-
isStatic
public boolean isStatic()Returns the state of the actor on whether it is static or not. A static actor does not move and is not affected by gravity. It will not be updated in the debug menus- Returns:
- boolean indicating if the actor is static
-
setStatic
public boolean setStatic(boolean isStatic) Sets the state of the actor to static or not.- Parameters:
isStatic-- Returns:
- boolean indicating if the state was successfully set
-
act
public abstract void act()Performs the actor's action. -
enableInventory
public void enableInventory()Enables inventory for the actor. By default, it is disabled. -
disableInventory
public void disableInventory()Disables the actor's inventory. Clears the inventory list and sets it to null. -
getInventorySize
public int getInventorySize()Gets the maximum size of the actor's inventory.- Returns:
- The maximum size of the inventory.
-
setInventorySize
public void setInventorySize(int size) Sets the inventory size- Parameters:
size- the maximum inventory size (maximum number of type Item)
-
hasInventory
public boolean hasInventory()Checks if the actor has an inventory.- Returns:
- true if the actor has an inventory, false otherwise.
-
addItem
Adds an item to the actor's inventory.- Parameters:
item- The item to add to the inventory.- Returns:
- Boolean the success of adding the item
-
removeItem
Removes an item from the actor's inventory.- Parameters:
item- The item to remove from the inventory.
-
getInventory
-
setLocation
public void setLocation(int x, int y) Sets the location of the actor.- Parameters:
x- The x-coordinate of the new location.y- The y-coordinate of the new location.
-
getX
public int getX()Gets the x-coordinate of the actor's location.- Returns:
- The x-coordinate of the actor's location.
-
setX
public void setX(int x) Sets the x-coordinate of the actor's location.- Parameters:
x- The x-coordinate to set.
-
getY
public int getY()Gets the y-coordinate of the actor's location.- Returns:
- The y-coordinate of the actor's location.
-
setY
public void setY(int y) Sets the y-coordinate of the actor's location.- Parameters:
y- The y-coordinate to set.
-
getWidth
public int getWidth()Returns the width of the Actor- Returns:
- int Actor width in Activerse Unit (relative)
-
setWidth
public void setWidth(int width) Sets the width of the actor.- Parameters:
width- The width to set.
-
getImage
Gets the image of the actor.- Returns:
- The image of the actor, or null if no image is set.
-
setImage
Sets the image of the actor.- Parameters:
image- The image to set for the actor.
-
paint
Draws the actor on the given graphics context.- Parameters:
g- The graphics context to draw on.
-
getWorld
Gets the world that the actor belongs to.- Returns:
- The world that the actor belongs to.
-
setWorld
Sets the world that the actor belongs to.- Parameters:
world- The world that the actor belongs to.
-
intersects
Checks if this actor intersects with another actor.- Parameters:
other- The other actor to check for intersection.- Returns:
- true if this actor intersects with the other actor, false otherwise.
-
move
public void move(int distance) Moves the actor in its current direction by the specified distance.- Parameters:
distance- The distance to move the actor.
-
turn
public void turn(double angle) Turns the actor by the specified angle.- Parameters:
angle- The angle to turn the actor (in radians).
-
getOneIntersectingObject
Finds the intesrsectiuon of the actor with another actor then returns it- Returns:
- The intersecting actor, or null if no intersection is found.
-
delayNext
public void delayNext(int ms) Delays the execution of the next action by the specified milliseconds.- Parameters:
ms- The delay in milliseconds.
-
keyIsDown
public boolean keyIsDown(char key) Checks if a specific key is currently pressed.- Parameters:
key- The character representing the key to check.- Returns:
- true if the key is currently pressed, false otherwise.
-
getVelocityX
public double getVelocityX()Gets the horizontal velocity of the actor.- Returns:
- The horizontal velocity of the actor.
-
setVelocityX
public void setVelocityX(double velocityX) Sets the horizontal velocity of the actor.- Parameters:
velocityX- The horizontal velocity to set.
-
getVelocityY
public double getVelocityY()Gets the vertical velocity of the actor.- Returns:
- The vertical velocity of the actor.
-
setVelocityY
public void setVelocityY(double velocityY) Sets the vertical velocity of the actor.- Parameters:
velocityY- The vertical velocity to set.
-
getHeight
public int getHeight()Gets the height of the actor.- Returns:
- The height of the actor.
-
setHeight
public void setHeight(int height) Sets the height of the actor.- Parameters:
height- The height to set.
-
useAStar
Gets the direction of the actor.- Parameters:
other- The actor to followx- The number of iterations to follow the actor (seconds)
-