Package ActiverseEngine
Class Actor
java.lang.Object
ActiverseEngine.Actor
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
act()
Performs the actor's action.void
delayNext
(int ms) Delays the execution of the next action by the specified milliseconds.protected Rectangle
Gets the bounding box of the actor.int
Gets the height of the actor.getImage()
Gets the image of the actor.Finds the intesrsectiuon of the actor with another actor then returns itdouble
Gets the horizontal velocity of the actor.double
Gets the vertical velocity of the actor.int
getWidth()
getWorld()
Gets the world that the actor belongs to.int
getX()
Gets the x-coordinate of the actor's location.int
getY()
Gets the y-coordinate of the actor's location.boolean
intersects
(Actor other) Checks if this actor intersects with another actor.boolean
keyIsDown
(char key) Checks if a specific key is currently pressed.void
move
(int distance) Moves the actor in its current direction by the specified distance.void
Draws the actor on the given graphics context.void
setHeight
(int height) Sets the height of the actor.void
setImage
(ActiverseImage image) Sets the image of the actor.void
setLocation
(int x, int y) Sets the location of the actor.void
setVelocityX
(double velocityX) Sets the horizontal velocity of the actor.void
setVelocityY
(double velocityY) Sets the vertical velocity of the actor.void
Sets the world that the actor belongs to.void
setX
(int x) Sets the x-coordinate of the actor's location.void
setY
(int y) Sets the y-coordinate of the actor's location.void
turn
(double angle) Turns the actor by the specified angle.void
Gets the direction of the actor.
-
Field Details
-
direction
protected double direction
-
-
Constructor Details
-
Actor
public Actor()
-
-
Method Details
-
act
public abstract void act()Performs the actor's action. -
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() -
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.
-
getBoundingBox
Gets the bounding box of the actor.- Returns:
- The bounding box of the actor.
-
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)
-