Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

CSTile Class Reference

#include <CSTile.h>


Detailed Description

This file defines CSTile:
CSTile can only be created thru a loader (CSTileLoader). CSTile are defined by (now ONLY thru) an ini-File, like:

ID "PAC_LEFT_ACTION" IS_REPEATABLE ACTION_INVERSE_ONCE PHASES 0 ANIMATION "animation\\pac_left.ani"

ID - supposed a unique identifier REAPEATABLE - one of: ACTION_NOT_REPEATABLE 0 ACTION_REPEATABLE 1 ACTION_INVERSE_ONCE 2 ACTION_INVERSE_REPEATABLE 3 ACTION_RANDOM 4

PHASES - many phases, each phase is represented by a number the number corresponse to the ANIMATION that is loaded with the ini - file (numbered from top to bottom. NOTE: REAPEATABLE ACTION_INVERSE_ONCE PHASES 0 PHASES 1 PHASES 2 PHASES 3 PHASES 4

gives the same result as: REAPEATABLE ACTION_NOT_REPEATABLE PHASES 0 PHASES 1 PHASES 2 PHASES 3 PHASES 4 PHASES 3 PHASES 2 PHASES 1 PHASES 0

ANIMATION - many animations are possible! describes the animation to be loaded, parameter gives the ini-file for a CSAnimation

Only two methods are really needed: virtual bool next() // if finished and not repeat -> false, true otherwise

Definition at line 103 of file CSTile.h.

Public Member Functions

 CSTile (const CSTile &tile)
unsigned char getIDChar ()
virtual ~CSTile ()
virtual std::string getType ()
unsigned int getX ()
unsigned int getY ()
void setX (unsigned int x)
void setY (unsigned int y)
unsigned int getWitdh ()
unsigned int getHeight ()
SDL_Surface * getScaledTile (double factor)
void setMapPosition (unsigned int x, unsigned int y)
unsigned int getMapPositionX ()
 in pixel of World

unsigned int getMapPositionY ()
 in pixel of World

int getTileType ()
int getSubtype ()
void setChanged (bool b)
bool isChanged ()
virtual bool next (const CSDisplayParams &displayParams)
virtual void display ()
void setSolid (bool b)
bool isSolid ()
void setSecPerFrame (float secPerFrame)
AnimationStategetAnimationState ()
void scale (int width, int tilesX, int height, int tilesY)

Static Public Attributes

const char * CLASS = "CSTile"


Constructor & Destructor Documentation

CSTile::CSTile const CSTile tile  ) 
 

Definition at line 21 of file CSTile.cpp.

References LOG_ENTER, LOG_EXIT, mAnimation, mAnimationState, mId, mIdChar, mIsSolid, mSubtype, and mType.

00022 {
00023     static char *functionName="CSTile";
00024     LOG_ENTER 
00025     initialize();
00026 
00027     // since all Animations are singletons, we can reuse the animation from our parent
00028     mAnimation = tile.mAnimation;
00029     mAnimationState = tile.mAnimationState;
00030     mId = strdup(tile.mId);
00031     mIdChar = tile.mIdChar;
00032     mIsSolid = tile.mIsSolid;
00033     mType = tile.mType;
00034     mSubtype = tile.mSubtype;
00035     LOG_EXIT
00036 }

CSTile::~CSTile  )  [virtual]
 

Definition at line 68 of file CSTile.cpp.

References LOG_ENTER, and LOG_EXIT.

00069 {
00070     static char *functionName="~CSTile";
00071     LOG_ENTER 
00072     // since all Animations are singeltons!
00073     mAnimation = 0;
00074     if (mId != 0)
00075     {
00076         free(mId);
00077         mId = 0;
00078     }
00079     LOG_EXIT
00080 }


Member Function Documentation

unsigned char CSTile::getIDChar  )  [inline]
 

Definition at line 125 of file CSTile.h.

00125 {return mIdChar;}

virtual std::string CSTile::getType  )  [inline, virtual]
 

Definition at line 129 of file CSTile.h.

References CLASS.

00129 {return (std::string) CLASS;}

unsigned int CSTile::getX  )  [inline]
 

Definition at line 131 of file CSTile.h.

References AnimationState::mXPos.

Referenced by CSSprite::checkCollision(), CSSprite::checkCollisionPixels(), CSTileMap::getTileAtPixel(), CSTileMap::getTouchingTiles(), CSTileMap::isBorderTile(), CSTileMap::setTile(), and CSTileMap::update().

00131 {return mAnimationState.mXPos;}

unsigned int CSTile::getY  )  [inline]
 

Definition at line 132 of file CSTile.h.

References AnimationState::mYPos.

Referenced by CSSprite::checkCollision(), CSSprite::checkCollisionPixels(), CSTileMap::getTileAtPixel(), CSTileMap::getTouchingTiles(), CSTileMap::isBorderTile(), and CSTileMap::update().

00132 {return mAnimationState.mYPos;}

void CSTile::setX unsigned int  x  )  [inline]
 

Definition at line 133 of file CSTile.h.

References AnimationState::mXPos.

Referenced by CSTileMap::setOffset(), and CSTileMap::setTile().

00133 {mAnimationState.mXPos = x;}

void CSTile::setY unsigned int  y  )  [inline]
 

Definition at line 134 of file CSTile.h.

References AnimationState::mYPos.

Referenced by CSTileMap::setOffset(), and CSTileMap::setTile().

00134 {mAnimationState.mYPos = y;}

unsigned int CSTile::getWitdh  )  [inline]
 

Definition at line 136 of file CSTile.h.

References CSAnimation::getMaxX().

Referenced by CSSprite::checkCollision(), CSSprite::checkCollisionPixels(), CSTileMap::getTileAtPixel(), CSTileMap::getTouchingTiles(), CSTileMap::setOffset(), CSTileMap::setTile(), and CSTileMap::update().

00136 {return mAnimation->getMaxX();}

Here is the call graph for this function:

unsigned int CSTile::getHeight  )  [inline]
 

Definition at line 137 of file CSTile.h.

References CSAnimation::getMaxY().

Referenced by CSSprite::checkCollision(), CSSprite::checkCollisionPixels(), CSTileMap::getTileAtPixel(), CSTileMap::getTouchingTiles(), CSTileMap::setOffset(), CSTileMap::setTile(), and CSTileMap::update().

00137 {return mAnimation->getMaxY();}

Here is the call graph for this function:

SDL_Surface* CSTile::getScaledTile double  factor  )  [inline]
 

Definition at line 138 of file CSTile.h.

References CSAnimation::getScaledAnimation().

Referenced by CSTileMap::getScaledMap().

00139         {
00140             return mAnimation->getScaledAnimation(mAnimationState, factor);
00141         }

Here is the call graph for this function:

void CSTile::setMapPosition unsigned int  x,
unsigned int  y
[inline]
 

Definition at line 143 of file CSTile.h.

Referenced by CSTileMap::setTile().

00143 {mMapPosX = x;mMapPosY = y;}

unsigned int CSTile::getMapPositionX  )  [inline]
 

in pixel of World

Definition at line 144 of file CSTile.h.

unsigned int CSTile::getMapPositionY  )  [inline]
 

in pixel of World

Definition at line 145 of file CSTile.h.

int CSTile::getTileType  )  [inline]
 

Definition at line 146 of file CSTile.h.

00146 {return mType;}

int CSTile::getSubtype  )  [inline]
 

Definition at line 147 of file CSTile.h.

00147 {return mSubtype;}

void CSTile::setChanged bool  b  )  [inline]
 

Definition at line 148 of file CSTile.h.

Referenced by CSTileMap::resetScaledMap(), and CSTileMap::setTile().

00148 {mChanged = b;}

bool CSTile::isChanged  )  [inline]
 

Definition at line 149 of file CSTile.h.

00149 {return mChanged;}

virtual bool CSTile::next const CSDisplayParams displayParams  )  [inline, virtual]
 

Definition at line 150 of file CSTile.h.

References AnimationState::mDisplayParams, CSAnimation::next(), and CSAnimation::resetState().

Referenced by CSTileMap::update().

00151         {
00152             mAnimationState.mDisplayParams = displayParams;
00153             bool finished = false;
00154             finished = !(mAnimation->next(mAnimationState));
00155 
00156             if (finished)
00157             {
00158                 mAnimation->resetState(mAnimationState);
00159             } 
00160 
00161             return !finished;
00162         }

Here is the call graph for this function:

virtual void CSTile::display  )  [inline, virtual]
 

Definition at line 164 of file CSTile.h.

References CSAnimation::display().

Referenced by CSTileMap::display().

00165         {
00166             mAnimation->display(mAnimationState);
00167         }

Here is the call graph for this function:

void CSTile::setSolid bool  b  ) 
 

Definition at line 90 of file CSTile.cpp.

References LOG_ENTER, LOG_EXIT, and CSAnimation::setSolid().

Referenced by CSTileSet::setSolid(), and CSTileSet::setTile().

00091 {
00092     static char *functionName="setSolid";
00093     LOG_ENTER 
00094     mIsSolid = b;
00095     mAnimation->setSolid(mIsSolid);
00096     LOG_EXIT
00097 }

Here is the call graph for this function:

bool CSTile::isSolid  )  [inline]
 

Definition at line 170 of file CSTile.h.

00170 {return mIsSolid;}

void CSTile::setSecPerFrame float  secPerFrame  ) 
 

Definition at line 82 of file CSTile.cpp.

References LOG_ENTER, LOG_EXIT, and CSAnimation::setSecPerFrame().

Referenced by CSTileSet::setSecPerFrame(), and CSTileSet::setTile().

00083 {
00084     static char *functionName="setSecPerFrame";
00085     LOG_ENTER 
00086     mAnimation->setSecPerFrame(secPerFrame);
00087     LOG_EXIT
00088 }

Here is the call graph for this function:

AnimationState* CSTile::getAnimationState  )  [inline]
 

Definition at line 172 of file CSTile.h.

Referenced by CSSprite::checkCollision(), CSSprite::checkCollisionPixels(), and CSTileMap::getScaledMap().

00172 {return &mAnimationState;}

void CSTile::scale int  width,
int  tilesX,
int  height,
int  tilesY
 

Definition at line 126 of file CSTile.cpp.

References LOG_ENTER, LOG_EXIT, and CSAnimation::scale().

Referenced by CSTileSet::scaleToFit().

00127 {
00128     static char *functionName="scale";
00129     LOG_ENTER 
00130     mAnimation->scale(width, tilesX, height, tilesY);
00131     LOG_EXIT
00132 }

Here is the call graph for this function:


Field Documentation

const char * CSTile::CLASS = "CSTile" [static]
 

Definition at line 9 of file CSTile.cpp.

Referenced by getType().


Generated on Wed Jul 14 00:45:14 2004 for CSLib by doxygen 1.3.6