DSOL::Sprites::AffineMatrix Class Reference

a class that holds data about rotating and scaling a sprite. More...

#include <AffineMatrix.hpp>

Inheritance diagram for DSOL::Sprites::AffineMatrix:

DSOL::IUpdater

List of all members.

Public Member Functions

 AffineMatrix (const uint index, const bool useMainOam=true)
 the constructor that creates an AffineMatrix object.
const int gethdx () const
 returns the 1st value of the affine matrix
const int gethdy () const
 returns the 2nd value of the affine matrix
const uint getIndex () const
 returns the rotation index of the object.
bool getMainEngine () const
 returns if the sprite uses the main oam or not.
const int getvdx () const
 returns the 3th value of the affine matrix
const int getvdy () const
 returns the 4th value of the affine matrix
AffineMatrixoperator= (const AffineMatrix &source)
 the asignment operator, will copy everything exept the index.
AffineMatrixsetAffineTransformation (const int hdx, const int hdy, const int vdx, const int vdy)
 allows you to directly sets the affine transformation matrix
AffineMatrixsetAngleScale (const int angle=0, const int scaleX=(1<< 8), const int scaleY=(1<< 8))
 sets the angle and scale of the object.
AffineMatrixsetIndex (const uint index)
 sets the rotation index of the object.
AffineMatrixsetMainEngine (const bool useMainOam=true)
 sets the AffineMatrix's engine.
virtual void update ()
 this will update the AffineMatrix object.

Static Public Member Functions

static void freeAffineMatrix (const uint AffineMatrixIndex, const bool mainOAM=true)
 frees a AffineMatrix index so other sprites can use it.
static uint reserveEmptyAffineMatrix (const bool mainOAM=true)
 reserves an empty AffineMatrix index to use.

Static Public Attributes

static const uint NUMBER_OF_AFFINE_MATRIXES = 32
 a constant for the number of affine matrixes available per sprite engine


Detailed Description

a class that holds data about rotating and scaling a sprite.

sprite(s) can use objects of this class to manage information about scaling and rotating sprites. there can be at most 32 objects (index 0-31) (the hardware wont allow more), but multiple sprites can use the same AffineMatrix object.


Constructor & Destructor Documentation

DSOL::Sprites::AffineMatrix::AffineMatrix ( const uint  index,
const bool  useMainOam = true 
) [inline]

the constructor that creates an AffineMatrix object.

Parameters:
index the index of the AffineMatrix in oam, must be (0-31).
useMainOam true if this AffineMatrix object is for sprites of the main engine, false for the sub engine. default is true.


Member Function Documentation

static void DSOL::Sprites::AffineMatrix::freeAffineMatrix ( const uint  AffineMatrixIndex,
const bool  mainOAM = true 
) [inline, static]

frees a AffineMatrix index so other sprites can use it.

this will free a AffineMatrix index that has been reserved with reserveEmptyAffineMatrix() so that other sprites can use it.

Parameters:
mainOAM true if the AffineMatrix index is for the main oam, false otherwise
AffineMatrixIndex the index to be freed, should be an index gotten with reserveEmptyAffineMatrix()

const int DSOL::Sprites::AffineMatrix::gethdx (  )  const [inline]

returns the 1st value of the affine matrix

Returns:
the 1st value of the affine matrix

const int DSOL::Sprites::AffineMatrix::gethdy (  )  const [inline]

returns the 2nd value of the affine matrix

Returns:
the 2nd value of the affine matrix

const uint DSOL::Sprites::AffineMatrix::getIndex (  )  const [inline]

returns the rotation index of the object.

Returns:
the rotation index.

bool DSOL::Sprites::AffineMatrix::getMainEngine (  )  const [inline]

returns if the sprite uses the main oam or not.

Returns:
true if it uses the main oam, false otherwise

const int DSOL::Sprites::AffineMatrix::getvdx (  )  const [inline]

returns the 3th value of the affine matrix

Returns:
the 3th value of the affine matrix

const int DSOL::Sprites::AffineMatrix::getvdy (  )  const [inline]

returns the 4th value of the affine matrix

Returns:
the 4th value of the affine matrix

AffineMatrix& DSOL::Sprites::AffineMatrix::operator= ( const AffineMatrix source  )  [inline]

the asignment operator, will copy everything exept the index.

Parameters:
source the affine matrix to copy from.
Returns:
a reference to the object, so you can chain multiple commands.

static uint DSOL::Sprites::AffineMatrix::reserveEmptyAffineMatrix ( const bool  mainOAM = true  )  [static]

reserves an empty AffineMatrix index to use.

this will check if there are AffineMatrix indexes that hasn't been reserved yet, and reserves and returns it if there are onreserved AffineMatrix. there are 32 AffineMatrix for main oam and 32 for sub engine.

Parameters:
mainOAM true if the Affine Matrix is for the main oam, false otherwise
Returns:
the index of an unreserved AffineMatrix index (which has been reserved for you) or NUMBER_OF_AFFINE_MATRIXES if there are no AffineMatrix indexes left (will display an error in debug mode)

AffineMatrix& DSOL::Sprites::AffineMatrix::setAffineTransformation ( const int  hdx,
const int  hdy,
const int  vdx,
const int  vdy 
) [inline]

allows you to directly sets the affine transformation matrix

with this, you have more freedom to set the matrix, but it might be more difficult to use if you're not used to affine transformation matrix.

Parameters:
hdx the 1st matrix value
hdy the 2nd matrix value
vdx the 3th matrix value
vdy the 4th matrix value
Returns:
a reference to the object, so you can chain multiple commands.

AffineMatrix& DSOL::Sprites::AffineMatrix::setAngleScale ( const int  angle = 0,
const int  scaleX = (1<< 8),
const int  scaleY = (1<< 8) 
)

sets the angle and scale of the object.

the angle can be one of the spriteAngle enum values, a 360 degree value converted with libnds's degreesToAngle() macro function, or an 32 bits int if you need precision. the scale values are in .8 fixed point format.

Parameters:
angle the new angle of the object, in the format that libnds uses (32768 degrees), default is 0 (no angle).
scaleX the value to scale the x ax with.
scaleY the value to scale the y ax with.
Returns:
a reference to the object, so you can chain multiple commands.

AffineMatrix& DSOL::Sprites::AffineMatrix::setIndex ( const uint  index  )  [inline]

sets the rotation index of the object.

Parameters:
index the new index of the object.
Returns:
a reference to the object, so you can chain multiple commands.

AffineMatrix& DSOL::Sprites::AffineMatrix::setMainEngine ( const bool  useMainOam = true  )  [inline]

sets the AffineMatrix's engine.

puts the sprite on the main or the sub engine.

Parameters:
useMainOam true if the sprite should be on the main engine, false for the sub engine. default is true.
Returns:
a reference to the object, so you can chain multiple commands.

virtual void DSOL::Sprites::AffineMatrix::update (  )  [inline, virtual]

this will update the AffineMatrix object.

this will copy the data to oam so sprites can use it.

Implements DSOL::IUpdater.


Member Data Documentation

a constant for the number of affine matrixes available per sprite engine


The documentation for this class was generated from the following file:

Generated on Thu Aug 6 18:17:50 2009 for DSOL by  doxygen 1.5.8