PropaneActor Class Reference

A 2D sprite based actor with simple animation and collision support. Can be overridden for NetworkActor, Propane3DActor, etc. More...

#include <PropaneActor.h>

List of all members.

Public Member Functions

 PropaneActor (SpriteManager *sprites)
 Create with a given sprite manager as parent.
virtual ~PropaneActor ()
 Destructor for this actor.
void setAnimation (int startFrame, int numFrames, float frameDelay)
 Allows you to override animation values permanently. This will not affect any temporary frames currently active.
virtual void draw (int x, int y)
 Draw the actor, based on the provided camera coordinate in worldspace. (x,y) is the CENTRE of what the camera is LOOKING AT (i.e. where the camera "is").
virtual void move (float dx, float dy)
 Move the actor some number of world units.
virtual void temporaryFrame (int frame)
 Allows you to temporarily override standard animation, for a single frame. Resets the animation timer.
virtual void resetAnimation ()
 Resets your animation to base values, including resetting the timer and clearing out temporary frames.
virtual bool rotateTowards (double maxRot, double goal)
 Make the actor face a certain angle "over time". Very useful for smooth, human-like turning.
virtual void rotateFacing (float x, float y)
 Forces the actor to instantly turn towards a given (x,y) in worldspace.
float getX ()
 Get the actor's current horizontal (east-west) world coordinate.
float getY ()
 Get the actor's current vertical (north-south) world coordinate.
float getWidth ()
 Get the actor's width in world units. This affects drawing and collision.
float getHeight ()
 Get the actor's height in world units. This affects drawing and collision.
float getForwardX (float delta, float offsetx=0.0f, float offsety=0.0f)
 Gets a point ahead of the actor at "delta" distance. Use offsetx and offsety to get a point on the actor ahead (for example, their hand to place a gun in it).
float getForwardY (float delta, float offsetx=0.0f, float offsety=0.0f)
 Gets a point ahead of the actor at "delta" distance. Use offsetx and offsety to get a point on the actor ahead (for example, their hand to place a gun in it).
virtual double getRotation ()
 Get current actor rotation (in degrees).
virtual double angleTowards (float wx, float wy)
 Get the actor's angle towards a certain location in worldspace.
virtual double angleDistance (double angle1, double angle2)
 Get the arc length required to turn towards a world loc (in terms of degrees).
virtual double angleOutOf360 (double angle)
 Get an angle in degrees out of 360.
void setX (float newX)
 Set the actor's X (horizontal, east-west) coordinate in world units.
void setY (float newY)
 Sets the actor's Y (vertical, north-south) coordinate in world units.
void setWidth (float width)
 Sets actor width in world units, affecting collision and rendering.
void setHeight (float height)
 Sets actor height in world units, affecting collision and rendering.
void setXYWH (float x, float y, float width, float height)
 Sets actor (X,Y) position and dimensions at the same time.
virtual void setRotation (double degrees)
 Instantly sets the actor's rotation to a given angle in degrees.
virtual void rotate (double dRot)
 Changes the actor's current rotation by dRot degrees.
virtual bool collision (PropaneActor *actor2)
 Returns true if it collided with another PropaneActor object. Uses the other object's getX/getY/getWidth/getHeight methods to do so.
int getFrame ()
 Gets the sprite that should be used for rendering this actor's current animation frame.
void updateAnimation (float delta)
 Updates the animation timer, incrementing frames as necessary. Delta is in seconds.
virtual void handleTrigger (std::string trigger_uid)
 For purposes of scripting, take an event trigger UID and perform a variable action on it. Interface method.

Protected Member Functions

float DegToRad (double degree)
 Converts rotations in degrees to radians.
double rotationOutOf360 ()
 Returns the actor's current rotation out of 360 (in degrees).

Protected Attributes

int startFrame
 The first frame in the animation sequence.
float frameTimer
 The amount of time the current frame has spent.
float frameDelay
 The amount of time a frame can take before it advances.
int curFrame
 The offset from the first frame in the series.
int numFrames
 How high the offset can get before it loops back to 0 (first frame).
float x
 X coordinate, world units.
float y
 Y coordinate, world units.
float w
 Width, world units (collision & render).
float h
 Height, world units (collision & render).
double rotation
 Current actor rotation (in degrees).
bool inTemp
 Are we in a temporary frame?
int tempFrame
 The id of the temporary frame.
SpriteManagermyMgr
 A pointer to the sprite manager that will render this actor, including the raw textures that tempFrame/startFrame reference.


Detailed Description

A 2D sprite based actor with simple animation and collision support. Can be overridden for NetworkActor, Propane3DActor, etc.


Constructor & Destructor Documentation

PropaneActor::PropaneActor ( SpriteManager sprites  ) 

Create with a given sprite manager as parent.

Constructs a new PropaneActor that links to the specified SpriteManager


Member Function Documentation

double PropaneActor::angleTowards ( float  wx,
float  wy 
) [virtual]

Get the actor's angle towards a certain location in worldspace.

Rotate the target actor to face a specified x,y coordinate in world space.

bool PropaneActor::collision ( PropaneActor actor2  )  [virtual]

Returns true if it collided with another PropaneActor object. Uses the other object's getX/getY/getWidth/getHeight methods to do so.

Detects a collision with another PropaneActor object. Returns true if collided.

float PropaneActor::DegToRad ( double  degree  )  [protected]

Converts rotations in degrees to radians.

Converts degrees out of 360 to radians out of 2 PI

void PropaneActor::draw ( int  x,
int  y 
) [virtual]

Draw the actor, based on the provided camera coordinate in worldspace. (x,y) is the CENTRE of what the camera is LOOKING AT (i.e. where the camera "is").

Draws the actor to screen using its current sprite, rotation, height, width and location, based on specified camera coordinates

int PropaneActor::getFrame (  ) 

Gets the sprite that should be used for rendering this actor's current animation frame.

Returns the current sprite that should be used to render this actor

float PropaneActor::getHeight (  ) 

Get the actor's height in world units. This affects drawing and collision.

Returns the height of the actor sprite

double PropaneActor::getRotation (  )  [virtual]

Get current actor rotation (in degrees).

Returns the actor's heading, in degrees

float PropaneActor::getWidth (  ) 

Get the actor's width in world units. This affects drawing and collision.

Returns the width of the actor sprite

float PropaneActor::getX (  ) 

Get the actor's current horizontal (east-west) world coordinate.

Returns the x-location of the actor in world space.

float PropaneActor::getY (  ) 

Get the actor's current vertical (north-south) world coordinate.

Returns the y-location of the actor in world-space.

void PropaneActor::move ( float  dx,
float  dy 
) [virtual]

Move the actor some number of world units.

Move the actor the specified amount.

void PropaneActor::resetAnimation (  )  [virtual]

Resets your animation to base values, including resetting the timer and clearing out temporary frames.

Re-initializes the animation to default values.

void PropaneActor::rotate ( double  dRot  )  [virtual]

Changes the actor's current rotation by dRot degrees.

Changes the rotation of the actor by the provided amount of degrees

bool PropaneActor::rotateTowards ( double  maxRot,
double  goal 
) [virtual]

Make the actor face a certain angle "over time". Very useful for smooth, human-like turning.

rotate the target actor towards a "goal" angle, useful for gradually turning towards things

double PropaneActor::rotationOutOf360 (  )  [protected]

Returns the actor's current rotation out of 360 (in degrees).

Returns the actor's rotation (in degrees) out of 360, rather than -INF to +INF

void PropaneActor::setAnimation ( int  startFrame,
int  numFrames,
float  frameDelay 
)

Allows you to override animation values permanently. This will not affect any temporary frames currently active.

Resets the animation's default values with provided start sprite, number of frames, and delay between frame iteration

void PropaneActor::setHeight ( float  height  ) 

Sets actor height in world units, affecting collision and rendering.

Set the render and collision height of the actor in world units

void PropaneActor::setRotation ( double  degrees  )  [virtual]

Instantly sets the actor's rotation to a given angle in degrees.

Sets the rotation to a given angle, in degrees

void PropaneActor::setWidth ( float  width  ) 

Sets actor width in world units, affecting collision and rendering.

Set the render and collision width of the actor in world units.

void PropaneActor::setX ( float  newX  ) 

Set the actor's X (horizontal, east-west) coordinate in world units.

Sets this actor's world X coordinate

void PropaneActor::setY ( float  newY  ) 

Sets the actor's Y (vertical, north-south) coordinate in world units.

Sets this actor's world Y coordinate

void PropaneActor::temporaryFrame ( int  frame  )  [virtual]

Allows you to temporarily override standard animation, for a single frame. Resets the animation timer.

Interrupts animation temporarily and substitutes a frame

void PropaneActor::updateAnimation ( float  delta  ) 

Updates the animation timer, incrementing frames as necessary. Delta is in seconds.

Increments animation timer and handles frame advancement from given delta interval


The documentation for this class was generated from the following files:
Generated on Thu Aug 31 20:26:03 2006 for Propane Injector by  doxygen 1.4.7