All Packages  This Package  Previous  Next  Index

Class gamelet.Actor

java.lang.Object
   |
   +----gamelet.Actor

public abstract class Actor
extends Object

Constructor Index

 o Actor(Gamelet)
Initializes the actor

Method Index

 o bounceOff(Actor)
Bounce off the specified Actor.
 o calculateCurrentFrame()
Calculates the current frame.
 o calculateNewPosition()
Calculates the new X and Y position based on velocity and time.
 o checkForOutOfBounds()
Check for out of bounds and wrap if it is.
 o collideWithActor(Actor)
Override this method to handle the case when Actor collides with another.
 o draw(Graphics)
Each Actor is handed a g and is expected to draw itself in it.
 o getCurrentFrame()
return current frame index which will be displayed next.
 o getGamelet()
Return the Gamelet.
 o getHeight()
return height of actor image.
 o getNumFrames()
Return the number of frames, the actor image consists of.
 o getWidth()
return width of actor image.
 o getWrapAround()
Get current wraparound behaviour.
 o getXPos()
get x Position of this actor.
 o getXVelocity()
Get Velocity in X Dimension.
 o getYPos()
get y position of this actor.
 o getYVelocity()
Get Velocity in Y Dimension.
 o setCurrentFrame(int)
set the current frame index.
 o setImage(Image)
Set the image used for animation.
 o setImage(Image, int, int)
Set the image used for animation.
 o setImage(Image, int, int, int, int)
Set the image used for animation.
 o setWrapAround(boolean)
Change wraparound behaviour.
 o setXPos(double)
set x Position of this actor.
 o setXVelocity(double)
Set Velocity in X Dimension.
 o setYPos(double)
set y position of this actor.
 o setYVelocity(double)
Set Velocity in Y Dimension.

Constructors

 o Actor
 public Actor(Gamelet theOwner)
Initializes the actor

Parameters:
theOwner - the gamelet, in which the actor should be located. This parameter can later be extracted by the getGamelet() Method.

Methods

 o getXPos
 public double getXPos()
get x Position of this actor. Position refers to upper left corner of the actor image.

 o setXPos
 public void setXPos(double new_x)
set x Position of this actor. Position refers to upper left corner of the actor image.

 o getYPos
 public double getYPos()
get y position of this actor. Position refers to upper left corner of the actor image.

 o setYPos
 public void setYPos(double new_y)
set y position of this actor. Position refers to upper left corner of the actor image.

 o getWidth
 public double getWidth()
return width of actor image. This is computed by the setImage()-Methods.

 o getHeight
 public double getHeight()
return height of actor image. This is computed by the setImage()-Methods.

 o getCurrentFrame
 public int getCurrentFrame()
return current frame index which will be displayed next.

 o setCurrentFrame
 public void setCurrentFrame(int new_currentFrame)
set the current frame index. This is the index of the frame, which will be displayed next.

 o getNumFrames
 public int getNumFrames()
Return the number of frames, the actor image consists of. This is computed by the setImage()-Methods.

 o getWrapAround
 public boolean getWrapAround()
Get current wraparound behaviour. When wraparound is on, actors which will move past one border will apear again on the other side after a while. When wraparound is switched off, you are responsible to check that the actor will remain inside the visible area.

 o setWrapAround
 public void setWrapAround(boolean new_wrapAround)
Change wraparound behaviour. When wraparound is on, actors which will move past one border will apear again on the other side after a while. When wraparound is switched off, you are responsible to check that the actor will remain inside the visible area.

 o getGamelet
 public Gamelet getGamelet()
Return the Gamelet. Through this method, the width and height of the visible area can be extracted. Also, new actors can be added or existing ones removed.

 o getXVelocity
 public double getXVelocity()
Get Velocity in X Dimension. The unit of the velocity is screen pixels per second. The position is updated in regular intervals using this velocity.

 o setXVelocity
 public void setXVelocity(double new_vel_x)
Set Velocity in X Dimension. The unit of the velocity is screen pixels per second. The position is updated in regular intervals using this velocity.

 o getYVelocity
 public double getYVelocity()
Get Velocity in Y Dimension. The unit of the velocity is screen pixels per second. The position is updated in regular intervals using this velocity.

 o setYVelocity
 public void setYVelocity(double new_vel_y)
Set Velocity in Y Dimension. The unit of the velocity is screen pixels per second. The position is updated in regular intervals using this velocity.

 o setImage
 protected void setImage(Image theImage,
                         int frameXSize,
                         int frameYSize,
                         int framesHorizontally,
                         int totalFrames)
Set the image used for animation.

 o setImage
 protected void setImage(Image theImage)
Set the image used for animation. Good for an image that has all frames within it and none empty.

 o setImage
 protected void setImage(Image theImage,
                         int horizontalFrames,
                         int totalFrames)
Set the image used for animation. Good for an image that has some empty frames within it.

 o calculateNewPosition
 protected void calculateNewPosition()
Calculates the new X and Y position based on velocity and time. Also may check if Actor needs to wrap around at the edges if the wraparound flag is set.

 o calculateCurrentFrame
 protected void calculateCurrentFrame()
Calculates the current frame. Behaviour is to flip through frames sequentially and loop.

 o checkForOutOfBounds
 protected void checkForOutOfBounds()
Check for out of bounds and wrap if it is. This is called automatically if wrapAround is set to true with method setWrapAround().

 o draw
 public void draw(Graphics g)
Each Actor is handed a g and is expected to draw itself in it.

 o collideWithActor
 protected void collideWithActor(Actor theActor)
Override this method to handle the case when Actor collides with another.

 o bounceOff
 public void bounceOff(Actor theActor)
Bounce off the specified Actor. Changes it's velocity so that it appears to bounce off.


All Packages  This Package  Previous  Next  Index